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

Fredrik Lundh fredrik at pythonware.com
Wed Dec 20 14:48:29 EST 2006


Mark Peters wrote:

> However, the typical Python way to iterate through a list for be to
 > use a for loop.  Perhaps replace the while statement with:
> for Townshp in Townshps:
> and remove the "Townshp = Townshps.next()" lines

that assumes that the feature class list is actually a Python iterable, 
of course, and not just something that happens to have a "next" method.

:::

... and judging from the documentation

http://webhelp.esri.com/arcgisdesktop/9.1/index.cfm?TopicName=ListFeatureClasses%20method

it's not an iterable.

:::

you could of course replace the

     fcs = gp.ListFeatureClasses()
     fc = fcs.next()
     while fc:
         ...
         fc = fcs.next()

pattern with

    for fc in iter(gp.ListFeatureClasses().next, None):
        ...

but maybe that's a bit too clever for an absolute novice ;-)

</F>




More information about the Python-list mailing list