Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

i'm recently using Python for my Processing work that I do with ArcGis 9.3. I figured out, that using Eclipse (with PyDev) could be helpfull for debugging purpose. The geoprocessor is starting as demanded.

Nevertheless i got into trouble using a Example-Script from Esri: http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=fieldmappings_properties

fcs = gp.ListFeatureClasses("block*", "Polygon")

for fc in fcs:

This causes an error:

File "C:\Python26\lib\site-packages\win32com\client\dynamic.py", line 228, in __getitem__
    raise TypeError, "This object does not support enumeration"

The Script works fine when starting from ArcCatalog! It seems that the variable "fcs" is of type "instance" and that python ain't able to enumerate this type.

But why doesn't ArcGis have a problem with this? Does anybody know this? :)

Greetings, Markus

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

You can work around this using this idiom:

fcs = gp.ListFeatureClasses("block*", "Polygon")
for fc in iter(fcs.next, None):
share|improve this answer
    
Thank you, this seems to work for eclipse. But ArcGis/ArcCatalog seems to have a problem now: <type 'exceptions.AttributeError'>: 'list' object has no attribute 'next' Failed to execute (Script). In Eclipse there is another error now in this line fcs = gp.ListFeatureClasses("block*", "Polygon") for fc in iter(fcs.next, None): fieldmappings.AddTable(fc) fieldmappings.AddTable(fc) File "<COMObject <unknown>>", line 2, in AddTable If i have to fix every upcoming error with a workarround i better stick to starting scripts in ArcGis. Thanks for your Help :) Markus –  Markus Jun 12 '11 at 11:58
    
Sorry but the Formatting seems to be lost. :( –  Markus Jun 12 '11 at 12:35
    
This absolutely should not be happening if you're using the same code in both environments. How are you creating the geoprocessor? –  Jason Scheirer Jun 12 '11 at 16:10
    
gp = arcgisscripting.create(9.3) –  Markus Jun 15 '11 at 16:22
    
Yeah, that's a bug. You'll need to do some awful workaround like for fc in iter(getattr(fcs, 'next', fcs), None): –  Jason Scheirer Jun 15 '11 at 16:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.