Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'from:addr:python': 0.09; 'mentions': 0.09; 'subject:setting': 0.09; 'def': 0.15; 'argument': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'row': 0.16; 'rows': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.22; 'name?': 0.23; 'code': 0.25; '(in': 0.26; 'received:84': 0.28; 'import': 0.28; 'print': 0.29; 'exist.': 0.30; 'error': 0.32; 'does': 0.32; 'to:addr:python-list': 0.33; 'header:User- Agent:1': 0.34; 'recognize': 0.34; 'reply-to:addr:python.org': 0.34; 'subject:work': 0.34; 'skip:" 10': 0.36; 'not,': 0.38; 'too,': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'url:en': 0.39; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'url:index': 0.61; 'below': 0.62; 'url:10': 0.64; 'url:0': 0.69; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'url:help': 0.72; 'subject:make': 0.73; 'subject:value': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqQHAPQiaE7Unw4S/2dsb2JhbABDmTCOQniBRgEBBThAEQsIEAkUAg8JAwIBAgENKg4TCAEBh3MCt1iGawSLdUmMBoRrhxo Date: Thu, 08 Sep 2011 03:11:07 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: how to make fxn argument work with setting a field value References: <7732a253-c834-4578-93eb-930346247e57@b20g2000vbz.googlegroups.com> In-Reply-To: <7732a253-c834-4578-93eb-930346247e57@b20g2000vbz.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315447873 news.xs4all.nl 2444 [2001:888:2000:d::a6]:46234 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12940 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