Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12940
| Date | 2011-09-08 03:11 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: how to make fxn argument work with setting a field value |
| References | <7732a253-c834-4578-93eb-930346247e57@b20g2000vbz.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.861.1315447873.27778.python-list@python.org> (permalink) |
On 08/09/2011 02:32, noydb wrote: > What do I need to do to line 14 code below to get it to recognize the > field name and not the argument name? > > I get this error with below code at line 13, the print row.rankFld > line >> RuntimeError: Row: Field rankFld does not exist > A field called rankFld does not, should not exist. rankFld is > "RANKa" (in this first iteration), which does exist (gets added in > line 6, verified). > Line 14 fails too, if 13 is commented out. > > > ## > import arcpy > > fc = r"C:\test\scratch.gdb\sort_test1" > > def rank(inFC, outFC, scoreFld, popFld, rankFld): > arcpy.AddField_management(inFC, rankFld, "LONG") > arcpy.management.Sort(inFC, outFC, [[scoreFld, "DESCENDING"], > [popFld, "DESCENDING"]]) > i = 0 > print rankFld #>RANKa > rows = arcpy.UpdateCursor(fc) > for row in rows: > i = i + 1 > print row.rankFld > row.rankFld = i ## line 14 > rows.updateRow(row) > > return sortedFC > # > > out1 = r"C:\test\scratch.gdb\rankfxn6" > out2 = r"C:\test\scratch.gdb\rankfxn7" > > rank(fc, out1, "SCOREa", "COUNT1", "RANKa") > rank(out1, out2, "SCOREb", "COUNT2", "RANKb") > ## The documentation mentions "getValue" and "setValue": http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to make fxn argument work with setting a field value noydb <jenn.duerr@gmail.com> - 2011-09-07 18:32 -0700
Re: how to make fxn argument work with setting a field value MRAB <python@mrabarnett.plus.com> - 2011-09-08 03:11 +0100
Re: how to make fxn argument work with setting a field value noydb <jenn.duerr@gmail.com> - 2011-09-08 00:59 -0700
Re: how to make fxn argument work with setting a field value MRAB <python@mrabarnett.plus.com> - 2011-09-08 16:06 +0100
csiph-web