What is Python equivalent of ModelBuilder's Iterate Feature Selection?

Nick Ochoski is right about the SearchCursor, but there is a cleaner way to use it WITHOUT a while and manually calling next:

import arcpy
fc = "c:/data/base.gdb/roads"
field = "StreetName"
cursor = arcpy.SearchCursor(fc)
for row in cursor:
    print(row.getValue(field))

A SearchCursor in arcpy is the most direct route for accomplishing this:

import arcpy

fc = "c:/data/base.gdb/roads"
field = "StreetName"
cursor = arcpy.SearchCursor(fc)
row = cursor.next()
while row:
    print(row.getValue(field))
    row = cursor.next()

Note that you can use the where_clause property to perform your selection.


I think You can also add (to trevstanhope neat answer) a WITH for even cleaner code as it will delete cursor automatically after finishing

import arcpy
fc = "c:/data/base.gdb/roads"
field = "StreetName"
with arcpy.da.SearchCursor(fc) as cursor:
    for row in cursor:
        print(row.getValue(field))