By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,673 Members | 1,249 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,673 IT Pros & Developers. It's quick & easy.

Function object is not iterable

P: 2
here is a code snippet that is supposed to calculate Value2 by multiplying Wfactor and Value1 for identical object ID's.
Unfortunately the line with "Value2 =" casts a function object is not iterable error. I am stumped on where it is coming from.
Expand|Select|Wrap|Line Numbers
  1. testDict = {}
  2. for test in helps.getUniqueValues(fc,"ID"):
  3.             Value2 = ([c.getValue("Value1")*c.getValue("Wfactor") for c in arcpy.SearchCursor if c.getValue("ID") == test])
  4.             testDict[t] = Value2
  6.             cur = arcpy.UpdateCursor(fc)
  7.             for row in cur:
  8.                 row.setValue("Value2",testDict[row.getValue("ID")])
  9.                 cur.updateRow(row)
Sorry, I think my indentation got all messed up.
Happy 4th of July to everyone (in advance)!
Jul 3 '12 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 2.5K+
P: 2,851
Without knowing arcpy, I would guess arcpy.SearchCursor should be arcpy.SearchCursor().
Jul 3 '12 #2

P: 2
Hi bvdet,
that was a good idea. Adding the parentheses did not solve the issue though.
Jul 3 '12 #3

Expert 100+
P: 626
Expand|Select|Wrap|Line Numbers
  1. for c in arcpy.SearchCursor
If searchCursor is a function that does not return an iterable, then it would be the cause. Split the list comprehension into separate statements to see.
Expand|Select|Wrap|Line Numbers
  1. for c in arcpy.SearchCursor:
  2.     print c
  4. print "get value =", c.getValue("Value1")
  6. etc.
Jul 4 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.