I have a python label expression that works in arcmap, but when I try it in ArcPro, I get an AttributeError: "NoneType' object has not attribute 'strip'. I think this might happen because there are null values in my data (just a guess). Here is the expression:
def FindLabel ( [PAD_addr],[UnitsRes],[NumBldgs]):
S =[PAD_addr].strip()
i = S.find('(')
nres = long([UnitsRes])
nbldg = long([NumBldgs])
if i == -1:
tmp = S.replace('::','\n')
elif i > 0:
tmp = S[0:i]
if nbldg > 1:
tmp2 = ' on lot)'
else:
tmp2 = ')'
if nres == 0:
return tmp + '\n(no res units)'
elif nres == 1:
return tmp + '\n(' + str(nres) + ' res unit' + tmp2
else:
return tmp + '\n(' + str(nres) + ' res units' + tmp2
Any help would be appreciated.
Solved! Go to Solution.
@JoanHickey - this is a better solution for you.
Trap for null values and use a pass:
if <!field!> is null:
pass
else:
#do the rest of the mojo
(not tested...)
or query your data for null values, switch the selection, then use your function
Code formatting ... the Community Version - Esri Community
to make code easier to read
@JoanHickey - this is a better solution for you.
It was actually
if <!field!> == None:
pass
Thanks for the help.
Happy retirement!