Select to view content in your preferred language

Python Tool Error

720
1
07-19-2022 04:22 PM
tzz_12
by
Emerging Contributor

I created a python script for ArcGIS Pro tool I created. It worked fine a week ago, but for some reason, it now has this error: "ERROR 032659...TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'." What does this error mean and what are some possibilities for this type of error? 

Thanks ahead for your help!

Tags (2)
0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

It means that whatever line was trying to concatenate two things that were expecting strings and the first was "None"

a = None; b = "something"

a + str(b)
Traceback (most recent call last):

  File ",,,1.py", line 1, in <cell line: 1>
    a + str(b)

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Now you can fix it without solving the None problem by using

f"{a} + {b}"
'None + something'

f"{a}{b}"
'Nonesomething'

"{}{}".format(a, b)
'Nonesomething'

You will have to figure out why the first variable isn't getting what you want


... sort of retired...
0 Kudos