2

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 9.3 have a problem with this? Does anybody know this?

1 Answer 1

3

You can work around this using this idiom:

fcs = gp.ListFeatureClasses("block*", "Polygon")
for fc in iter(fcs.next, None):
5
  • 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, 2011 at 11:58
  • Sorry but the Formatting seems to be lost. :(
    – Markus
    Jun 12, 2011 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? Jun 12, 2011 at 16:10
  • gp = arcgisscripting.create(9.3)
    – Markus
    Jun 15, 2011 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): Jun 15, 2011 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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