TypeError: cannot concatenate 'str' and 'NoneType' objects

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Wed Dec 20 15:15:00 EST 2006


thompson.marisa at gmail.com a écrit :
> Hi.
> 
> I'm extremely new to Python and programming as a whole.  I have written
> a python script with the assistance of ESRI ArcGIS 9.2, which uses
> Python 2.4.1, however, it gives me this error when I try to run it.

Please post the full traceback. It's meant to help finding out what went 
wrong, you know...

> I've already posted at ESRI support, and I was hoping that Python
> people could help me more.
> 
> I hope there is something simple I could do to be able to define the
> object that it thinks is NoneType.

That's certainly not the solution...

>  Please when someone responds,
> please treat me as an absolute novice.
> 
> Thank you,
> Marisa
> 
> Here is my code:
> 
(snip)
> #Get list of Town Shapefiles
> Townshp = gp.ListFeatureClasses ("*")
(snip)
> 
> Townshp = Townshps.next()
> while Townshps !="":

1/ where does this "Townshps" comes from ?
2/ naming conventions are to use either all_lower (preferred) or at 
least mixedCase names for variables. And by all mean be consistent.
3/ if Townshp is a shortcut for Township, then it would be better to 
keep the full word
4/ the Python 'for' loop is meant to iterate over an iterable and taking 
care of boundaries, so you'd be better using it:

townships = gp.ListFeatureClasses ("*")
for township in townships:
   doSomethingWith(township)



More information about the Python-list mailing list