<?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: Defining a variable for field name in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331202#M25771</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;da cursor&lt;/A&gt; it's easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit:&lt;/P&gt;&lt;P&gt;For your current code on line 5 s will now hold the attribute from your "ADD_FULL" field of the first record in your feature class table.&lt;/P&gt;&lt;P&gt;if you add the below it should print the attribute of every record in your feature class &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(featureClass)&amp;nbsp;&amp;nbsp; 
row = rows.next()&amp;nbsp; 
#AddressFieldName = "ADD_FULL"&amp;nbsp; 
while row:&amp;nbsp; 
&amp;nbsp; s= row.ADD_FULL
&amp;nbsp; print s
&amp;nbsp; row = rows.next()
&lt;OL class="dp-py" start="1" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #5c5c5c; margin-bottom: 1px !important; margin-left: 45px !important;"&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 15:40:51 GMT</pubDate>
    <dc:creator>WesMiller</dc:creator>
    <dc:date>2021-12-11T15:40:51Z</dc:date>
    <item>
      <title>Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331201#M25770</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a code looks like this&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(featureClass) 
row = rows.next()
#AddressFieldName = "ADD_FULL"
while row:
&amp;nbsp; s= row.ADD_FULL&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to use the field name as variable but if I wan to try like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;s=row. + &lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;AddressFieldName&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;or such thing that I can think of won't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way that I can use it as variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331201#M25770</guid>
      <dc:creator>GyeyoungChoi</dc:creator>
      <dc:date>2021-12-11T15:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331202#M25771</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try using the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;da cursor&lt;/A&gt; it's easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit:&lt;/P&gt;&lt;P&gt;For your current code on line 5 s will now hold the attribute from your "ADD_FULL" field of the first record in your feature class table.&lt;/P&gt;&lt;P&gt;if you add the below it should print the attribute of every record in your feature class &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rows = arcpy.UpdateCursor(featureClass)&amp;nbsp;&amp;nbsp; 
row = rows.next()&amp;nbsp; 
#AddressFieldName = "ADD_FULL"&amp;nbsp; 
while row:&amp;nbsp; 
&amp;nbsp; s= row.ADD_FULL
&amp;nbsp; print s
&amp;nbsp; row = rows.next()
&lt;OL class="dp-py" start="1" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #5c5c5c; margin-bottom: 1px !important; margin-left: 45px !important;"&gt;&lt;LI&gt;&lt;/LI&gt;&lt;LI&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331202#M25771</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T15:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331203#M25772</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/16710" target="_blank"&gt;Wes Miller&lt;/A&gt; is right you should look into using the faster da cursor. If you want to continue using the cursor you are using then rather than accessing the field name directly as you have use this approach:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myField = "ADD_FULL" # You can change this to what ever field name you want
rows = arcpy.UpdateCursor(featureClass)&amp;nbsp;&amp;nbsp; 
row = rows.next()&amp;nbsp;&amp;nbsp; 
while row:&amp;nbsp;&amp;nbsp; 
&amp;nbsp; s= row.getValue(myField)
&amp;nbsp; print s 
&amp;nbsp; row = rows.next()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:40:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331203#M25772</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2021-12-11T15:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331204#M25773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying to get the field name in separate variable.&lt;/P&gt;&lt;P&gt;so I can received different field name from toolbox.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331204#M25773</guid>
      <dc:creator>GyeyoungChoi</dc:creator>
      <dc:date>2015-07-20T15:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331205#M25774</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand what your after did you want to move the data to another field or maybe use another field to manipulate the data? To get another field in the method your using you would just do x = row.someotherfield then s+x would equal the values of s and x. If you give me more details or an example I could help you better.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:35:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331205#M25774</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2015-07-20T15:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331206#M25775</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I explained it wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, simply I was trying to use a variable to indicate a name of filed (column name)&lt;/P&gt;&lt;P&gt;define, &lt;/P&gt;&lt;P&gt;AddressFieldName = "ADD_FIELD"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;then that field name has to be in&lt;/P&gt;&lt;P&gt;variable name s&lt;/P&gt;&lt;P&gt;but originally it works if I declare as (field[column] name ADD_FIELD)&lt;/P&gt;&lt;P&gt;s=row.ADD_FIELD&lt;/P&gt;&lt;P&gt;however I want to use ADD_FIELD&amp;nbsp; as variable&lt;/P&gt;&lt;P&gt;s=row+ "." + AddressFieldName&lt;/P&gt;&lt;P&gt;this returns error&lt;/P&gt;&lt;P&gt;or any other ways that I can think of.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:49:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331206#M25775</guid>
      <dc:creator>GyeyoungChoi</dc:creator>
      <dc:date>2015-07-20T15:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Defining a variable for field name in python</title>
      <link>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331207#M25776</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Duncan,&lt;/P&gt;&lt;P&gt;almost miss your reply&lt;/P&gt;&lt;P&gt;I'll try it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 15:51:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/defining-a-variable-for-field-name-in-python/m-p/331207#M25776</guid>
      <dc:creator>GyeyoungChoi</dc:creator>
      <dc:date>2015-07-20T15:51:41Z</dc:date>
    </item>
  </channel>
</rss>

