<?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: Convert expression in Calculate Field from VB to PYTHON3 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120344#M63065</link>
    <description>&lt;P&gt;Very good! Thank´s&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1325"&gt;@curtvprice&lt;/a&gt;&amp;nbsp;help a lot!&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2021 18:49:47 GMT</pubDate>
    <dc:creator>SoratoSouza_e_Silva</dc:creator>
    <dc:date>2021-11-25T18:49:47Z</dc:date>
    <item>
      <title>Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120015#M63051</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble converting this tool's expression to Python 3, could someone help me?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.CalculateField_management("selecionado_View", "selecionado_" + Safra + ".SELECIONADO", "[selecionado_" + Safra + ".SELECAO] + [selecionado_" + Safra2 + ".SELECAO]", "VB", "")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what this dot means.&lt;/P&gt;&lt;P&gt;Thank´s&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 18:18:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120015#M63051</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-24T18:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120025#M63052</link>
      <description>&lt;P&gt;Do you have the ability to generate this query in Pro SelectbyAttribute interface using python selection and then review the SQL query itself with the toggle?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 18:41:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120025#M63052</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-11-24T18:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120032#M63053</link>
      <description>&lt;P&gt;more&amp;nbsp; less I can´t simulate this field:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;selecionado_" + Safra + ".SELECIONADO", "[selecionado_" + Safra + ".SELECAO]&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 18:50:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120032#M63053</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-24T18:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120034#M63054</link>
      <description>&lt;P&gt;This looks like a field concatenation process.&amp;nbsp; Can you list the field names and the data type next to it?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 18:53:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120034#M63054</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-11-24T18:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120057#M63055</link>
      <description>&lt;P&gt;Safra = Text&lt;/P&gt;&lt;P&gt;Safra2 = Text&lt;/P&gt;&lt;P&gt;SELECAO = Text&lt;/P&gt;&lt;P&gt;"selecionado_" just string to concatenate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank´s&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 19:25:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120057#M63055</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-24T19:25:19Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120072#M63056</link>
      <description>&lt;P&gt;From the links I sent earlier, in Python field names are enclosed in exclamation marks&lt;/P&gt;&lt;P&gt;eg&amp;nbsp; &amp;nbsp;&lt;SPAN&gt;Safra&amp;nbsp; !Safra!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 19:41:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120072#M63056</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-11-24T19:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120075#M63057</link>
      <description>&lt;P&gt;Yes correct but I have problem after of the concatenate:&amp;nbsp;&lt;STRONG&gt;selecionado_" + Safra&lt;/STRONG&gt;, Safra = 2122 (Text)&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;NameError: name 'selecionado_2122' is not defined&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 19:45:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120075#M63057</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-24T19:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120076#M63058</link>
      <description>&lt;P&gt;Performing this exercise in Pro itself, as opposed to just adding it to a script, would be helpful to you to learn the syntax that is required per Dan's replies.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 19:45:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120076#M63058</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2021-11-24T19:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120088#M63059</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/219887"&gt;@SoratoSouza_e_Silva&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm having trouble converting this tool's expression to Python 3, could someone help me?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.CalculateField_management("selecionado_View", "selecionado_" + Safra + ".SELECIONADO", "[selecionado_" + Safra + ".SELECAO] + [selecionado_" + Safra2 + ".SELECAO]", "VB", "")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I'm not sure what this dot means&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What the dot means, from the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-join.htm" target="_self"&gt;help for Add Join&lt;/A&gt;:&lt;BR /&gt;&lt;EM&gt;In the resulting input table, fields will be prefixed with the input's name and a period (.), and all fields from the join table will be prefixed with the join table name and a period as the default.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Here's a crack at a Python 3 conversion. I second the suggestion in this thread that playing around with the Calculate Field tool interactively would help you learn some of the ins and outs of this, especially if you try &lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/analysis/geoprocessing/basics/run-geoprocessing-tools.htm#ESRI_SECTION1_14C98A99F1BA47FB976F252C8FC0BE50" target="_self"&gt;Copy as Python command&lt;/A&gt; after filling out the tool dialog. A key thing to keep in mind is the python string should be directly interpretable as a Python expression (with the exception of field names surrounded by ! characters) and data types are not converted for you as in VB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# I am assuming Safra, Safra2 are Python variables of type string.
tbl = "selecionado_" + Safra  # ex. selecionado_foo
tbl2 = "selecionado_" + Safra2 # ex. selecionado_foo2
# expr below becomes:
#  "!selecionado_foo.SELECAO! + !selecionado_foo2.SELECAO!"
expr = "!{}.SELECAO! + !{}.SELECAO!".format(tbl, tbl2)
arcpy.CalculateField_management("selecionado_View", 
    tbl + ".SELECIONADO", expr, "PYTHON") &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 20:16:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120088#M63059</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-11-24T20:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert expression in Calculate Field from VB to PYTHON3</title>
      <link>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120344#M63065</link>
      <description>&lt;P&gt;Very good! Thank´s&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1325"&gt;@curtvprice&lt;/a&gt;&amp;nbsp;help a lot!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 18:49:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-expression-in-calculate-field-from-vb-to/m-p/1120344#M63065</guid>
      <dc:creator>SoratoSouza_e_Silva</dc:creator>
      <dc:date>2021-11-25T18:49:47Z</dc:date>
    </item>
  </channel>
</rss>

