On Wed, 2006-12-20 at 11:33 -0800, Mark Peters wrote:
> Warning: I know nothing about the Python ArcGIS stuff.
> 
> The first thing that jumps out at me is your while condition.  You are
> testing "Townshps" when it seems from the code that you should be
> testing "Townshp".  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:

I was considering suggesting this, but I'm not sure there is much hope
that this would work. The posted code suggests that Townshps.next()
returns "" or None when the end of the list is reached. In order for the
for loop to work, it would have to raise StopIteration instead. (I
suppose it is conceivable that iter(Townshps) would return an object
that does behave in the required manner, but I wouldn't bet a lot of
money on that.)

Of the course if Townshps does not support the iteration protocol, the
for loop could still be written using the iter(callable,sentinel)
pattern, but let's not confuse this poor newbie more than necessary ;)

-Carsten


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to