Select to view content in your preferred language

Geoprocessing array: Directly iterate over items in a container

557
1
02-22-2022 03:33 PM
Status: Open
Labels (1)
Bud
by
Esteemed Contributor

The answer in this post describes it best: 
Why does "for point in part:" work in a standalone ArcPy script, but not in the Field Calculator?

The difference in behavior is due to the fact that objects within geoprocessing tools are not the same as objects within ArcPy. The pattern of directly iterating over items in a container, for point in part:, is a Python use pattern that is implemented in most ArcPy classes but not in ArcObjects classes being used by geoprocessing tools.

The geoprocessing array does not implement the __iter__ special method while ArcPy Array does implement it.

Idea:

Could ESRI please enhance the geoprocessing array so that we can directly iterate over items in a container?
Examples:

  • for part in geometry:
  • for point in part:


Thanks.

 

1 Comment
DanPatterson

yes! or just read arrays directly