ListFields issue

17 views
Skip to first unread message

devon...@gov.bc.ca

unread,
Oct 15, 2013, 5:35:15 PM10/15/13
to geop...@googlegroups.com
So here is my code,  I am trying to get this to work, and it worked fine in 9.3 but now does not want to work in 10.0.
 
Any thoughts??
 
fields = arcpy.ListFields(FDP_BLOCK)
field = fields.next()
test = "true"
while field:
    if field.name == "AGE_PROJ":
        test = "false"
    field = fields.next()
if test <> "false":
    arcpy.AddField_management(FDP_BLOCK, "AGE_PROJ", "SHORT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")

tarkenton

unread,
Oct 15, 2013, 5:52:51 PM10/15/13
to geop...@googlegroups.com, devon...@gov.bc.ca
Hey Devona

in 10.0 the ListFields method will return a native python list.  Take a look by printing the what is returned by the ListFields() method.

Its actually easier now to iterate through the fields.  The following code should work.

fields = arcpy.ListFields(FDP_BLOCK)
test = "true"
for field in fields:
    print 'field name:', field.name

    if field.name == "AGE_PROJ":
        test = "false"
Reply all
Reply to author
Forward
0 new messages