AnsweredAssumed Answered

List comprehension with statement using arcpy.da cursors?

Question asked by csny490 on Aug 10, 2012
Latest reply on Aug 13, 2012 by csny490
Excited to get my hands dirty using the arcpy.da module, and I appreciate the reasoning for the optional "with" statement syntax.

Question:

While it is possible to do this:

tileList = [r[0] for r in arcpy.da.SearchCursor(freq1Tbl, "TILE_NO")]
it doesn't seem possible to do this:
tileList = [row[0] for row in cursor with arcpy.da.SearchCursor(freq1Tbl, "TILE_NO") as cursor]


Am I using the wrong syntax here, or can you just not use the with statement in a list/dictionary comprehension?

Outcomes