<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to use a variable as an object property in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178850#M13736</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does that mean i can use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Row.getvalue(fieldname) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a direct replacement of what i am currently using? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Updaterow1.car1&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 May 2011 20:29:29 GMT</pubDate>
    <dc:creator>lukestudden</dc:creator>
    <dc:date>2011-05-05T20:29:29Z</dc:date>
    <item>
      <title>how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178846#M13732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using python (9.3) to automate the creation of numerous Featureclasses. Along the way I am adding a new column (field) to each which the field name is essentially a variable as it is all data driven. I am then using the UpdateCursor to update the value of the field with the value of another within the same Feature class. The problem is that since the field name I have added is a variable, I can not use the update cursor to refer to it as it changes after each loop iteration. Is there any way you can use a variable as an objects property, eg.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;instead of explicitly stating the field to be updated eg. updaterow1.car1 I would like to use a variable eg: updaterow1.carnumber&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Carnumber would then change after each iteration eg. car1, car2, car3 etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this possible?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 15:52:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178846#M13732</guid>
      <dc:creator>lukestudden</dc:creator>
      <dc:date>2011-05-05T15:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178847#M13733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000001q000000.htm"&gt;Accessing Data Using Cursors&lt;/A&gt;&lt;SPAN&gt;. Particularly the setValue and getValue methods.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 16:02:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178847#M13733</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-05-05T16:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178848#M13734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Logan,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks for the reply. I am still struggling to see this. Could you shed any more light on this at all? I would be most grateful! Below is a simplified version of what I have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;fieldname = "car "+ str(incrementingcounter)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;updaterows1 = gp.updatecursor(outputpoly1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;updaterow1 = updaterows1.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while updaterow1: # selects the entire row, but row has properties hence .fieldname&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #### i essentially need this to be something like updaterow1.fieldname&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updaterow1.count_0 = updaterow1.Join_Count &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updaterows1.updaterow(updaterow1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updaterow1 = updaterows1.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; del updaterows1&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 16:26:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178848#M13734</guid>
      <dc:creator>lukestudden</dc:creator>
      <dc:date>2011-05-05T16:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178849#M13735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are two basic ways to get and set field values on a row:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Using the field name, as in value = row.road_type&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Using getValue and setValue, as in value = row.getValue("road_type")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try using the getValue and setValue methods instead of using field names as properties.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 16:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178849#M13735</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-05-05T16:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178850#M13736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does that mean i can use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Row.getvalue(fieldname) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a direct replacement of what i am currently using? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Updaterow1.car1&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 20:29:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178850#M13736</guid>
      <dc:creator>lukestudden</dc:creator>
      <dc:date>2011-05-05T20:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: how to use a variable as an object property in python</title>
      <link>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178851#M13737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, they work the same way except that they allow you to pass a variable for the field name instead of hardcoding it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 May 2011 21:12:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-use-a-variable-as-an-object-property-in/m-p/178851#M13737</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2011-05-05T21:12:12Z</dc:date>
    </item>
  </channel>
</rss>

