<?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 VB to Python, Help? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259491#M19964</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I'll try that out Dan.&amp;nbsp; It is a model builder that uses the field calculator.&amp;nbsp; I should have clarified that.&amp;nbsp; I converted this to modelbuilder a few years ago from Avenue, but Avenue still works and VB stopped working.&amp;nbsp; Go Figure.&amp;nbsp; With windows 10 probably neither will work so it needs to be in Python now.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Aug 2017 15:35:33 GMT</pubDate>
    <dc:creator>TomMagdaleno</dc:creator>
    <dc:date>2017-08-07T15:35:33Z</dc:date>
    <item>
      <title>Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259488#M19961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all, I am new to Python and trying to make an older piece of code work.&amp;nbsp; It takes two tables, compares them, and if data in table A doesn't match table B it overwrites A with B.&amp;nbsp; &lt;/P&gt;&lt;P&gt;If they are equal it leaves them alone...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim intval&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt; [STR_NUM] = [SITUS_NR] then&lt;/P&gt;&lt;P&gt;intval = &lt;SPAN style="color: #800000;"&gt;" "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;intval = [STR_NUM]&lt;/P&gt;&lt;P&gt;end &lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If it finds a "nil" in a field in table B it clears the field in table A&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim intval&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt; [STR_NUM] = &lt;SPAN style="color: #800000;"&gt;"nil"&lt;/SPAN&gt; then&lt;/P&gt;&lt;P&gt;intval = &lt;SPAN style="color: #800000;"&gt;" "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;intval = [SITUS_NR]&lt;/P&gt;&lt;P&gt;end &lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Finally it overwrites table A if it finds data in table B&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dim intval&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt; [STR_NUM] &amp;lt;&amp;gt; &lt;SPAN style="color: #800000;"&gt;" "&lt;/SPAN&gt; &lt;SPAN style="color: #0000ff;"&gt;and&lt;/SPAN&gt; [STR_NUM] &amp;lt;&amp;gt; &lt;SPAN style="color: #800000;"&gt;"nil"&lt;/SPAN&gt; then&lt;/P&gt;&lt;P&gt;intval = [STR_NUM]&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;intval = [SITUS_NR]&lt;/P&gt;&lt;P&gt;end &lt;SPAN style="color: #0000ff;"&gt;if&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone help me convert these or at least one to Python?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 00:06:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259488#M19961</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-04T00:06:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259489#M19962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not applicable for file comparisons but could be implemented as a one-liner (line 11) or turned into a function (using lines 15-) for use within a program or the field calculator&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"""
if [STR_NUM] = [SITUS_NR] then
intval = " "
else
intval = [STR_NUM]
end if
"""&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# ---- as a field calculator expression or a line of code ----&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# for example a = 1, b = 2 or a = 'a', b = 'b'&lt;/SPAN&gt;

&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;" "&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; a&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;a &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# [False, True][condition check]&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# ---- more verbose&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; val &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;" "&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; val &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; a
&lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; val

&lt;SPAN class="comment token"&gt;# ---- more variations exist ----&lt;/SPAN&gt;
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:46:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259489#M19962</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T12:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259490#M19963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming the tables are small enough to be held in memory, you can use set comparisons:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;paths &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'table1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'path\t1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'table2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'path\t2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
sets &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;lambda&lt;/SPAN&gt; t&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;row &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;t&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;t&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; paths&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;values&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; len&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sets&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt; sets&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DeleteRows&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;paths&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'table1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;management&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Append&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;paths&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'table2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; paths&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'table1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: This compares the entire tables, not row-by-row, I might have misunderstood what you wanted..&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:46:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259490#M19963</guid>
      <dc:creator>ClintonDow1</dc:creator>
      <dc:date>2021-12-11T12:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259491#M19964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, I'll try that out Dan.&amp;nbsp; It is a model builder that uses the field calculator.&amp;nbsp; I should have clarified that.&amp;nbsp; I converted this to modelbuilder a few years ago from Avenue, but Avenue still works and VB stopped working.&amp;nbsp; Go Figure.&amp;nbsp; With windows 10 probably neither will work so it needs to be in Python now.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 15:35:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259491#M19964</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-07T15:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259492#M19965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;avenue to python is a far easier transition syntactically ... have fun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 17:10:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259492#M19965</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-07T17:10:59Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259493#M19966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just for the off-chance that it is VBA and not VB, and if you are using 10.5.x...&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;At the ArcGIS Desktop 10.5 release, Microsoft Visual Basic for Applications (VBA) Compatibility is no longer included. The VBA Compatibility setup in prior versions can still be installed, but its usage is not supported and may result in software errors or crashes. It is recommended that existing Microsoft VBA users continue to use ArcGIS Desktop version 10.2.2 or earlier, or migrate VBA customizations to &lt;A href="http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Building_add_ins_for_ArcGIS_Desktop/0001000000w2000000/" target="_blank"&gt;ArcMap add-ins&lt;/A&gt;, &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy/what-is-arcpy-.htm"&gt;ArcPy scripts&lt;/A&gt;, or ArcGIS Pro add-ins built with the &lt;A href="http://pro.arcgis.com/en/pro-app/sdk/" target="_blank"&gt;Pro SDK for .NET&lt;/A&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/latest/get-started/setup/arcgis-desktop-system-requirements.htm#ESRI_SECTION1_D4CA7AE6E828429ABDD8056F5D17FE8A" title="http://desktop.arcgis.com/en/arcmap/latest/get-started/setup/arcgis-desktop-system-requirements.htm#ESRI_SECTION1_D4CA7AE6E828429ABDD8056F5D17FE8A"&gt;ArcGIS Desktop 10.5.x system requirements—ArcGIS Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 17:20:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259493#M19966</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2017-08-07T17:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259494#M19967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So this is what I enter in the Field Calculator and I get a syntax error.&amp;nbsp; I thought maybe it was the colon in the first line but it makes no difference.&amp;nbsp; Can you spot the error?&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if&amp;nbsp; !STR_NUM! ==&amp;nbsp; !SITUS_NR!: &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val = " "&lt;BR /&gt;else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; val =&amp;nbsp; !STR_NUM! &lt;BR /&gt;return val&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 21:04:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259494#M19967</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-17T21:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259495#M19968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;func_shun&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="string token"&gt;"""to use... this function goes in the code block
&amp;nbsp;&amp;nbsp;&amp;nbsp; :&amp;nbsp; func_shun(!first_field!, !second_field!) ... goes in the expression box
&amp;nbsp;&amp;nbsp;&amp;nbsp; """&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; the_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;a &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# this is conceptual, replace a and b&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; the_result‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;your whole code block needs to go in a 'def' and indented 4 lines.&lt;/P&gt;&lt;P&gt;There is a 'code' block, which is where the 'def' goes, then there is an expression box, where the call to the function is made.&amp;nbsp; In the above example... you would put&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;func_shun(!STR_NUM!, !SITUS_NR!) &amp;nbsp;&lt;/P&gt;&lt;P&gt;in the expression box&lt;/P&gt;&lt;P&gt;same line if you fix up your other code block&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:46:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259495#M19968</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T12:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259496#M19969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Following up on &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;‌'s response:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/367465_fieldCalc1.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;It is also possible to do this in 1 line (without the codeblock section):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/367538_fieldCalc2.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Also, it looks like you are trying to compare strings and store the result in a field that holds a string (result_field in the photos).&amp;nbsp; If not, you may also need to do some type conversion:&lt;/P&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;[!STR_NUM!,""][!STR_NUM!==str(!SITUS_NR!)]&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Aug 2017 23:53:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259496#M19969</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-08-17T23:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259497#M19970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/rvburton"&gt;rvburton&lt;/A&gt;‌...&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&amp;nbsp; most don't like the latter since it wasn't tried earlier (line 11 in my previous post), but they are definitely more elegant, if you can remember the generic, the specific is easy&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 00:16:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259497#M19970</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-08-18T00:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259498#M19971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed.&amp;nbsp; I hadn't noticed the [ False, True ][ Condition ] check before this post.&amp;nbsp; It has a nice elegance to it, and it will come in handy. Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 00:25:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259498#M19971</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2017-08-18T00:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259499#M19972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Dan,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I think I get what we are trying to do, but I don't know why it isn't working.&amp;nbsp; See the error below.&amp;nbsp; This is with joined tables so the A and B names are a lot longer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="error" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/367518_codeblock.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 00:34:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259499#M19972</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-18T00:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259500#M19973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Per Dan's suggestion, paste the following code into the codeblock (top) section.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;func_shun&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; the_result &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;a &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; b&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; the_result
&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the lower section, paste only the following (I think I have the spelling of your joined tables correct):&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;func_shun&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; !asrerror_log_20170803&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;STR_NUM!&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; !cam_apn_old&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SITUS_NR!&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;VB would use square brackets around the field names, but Python uses exclamation marks.&amp;nbsp; So field calculator is getting confused.&amp;nbsp; You do have the Python parser selected.&amp;nbsp; The photo in my post below should help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:46:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259500#M19973</guid>
      <dc:creator>RandyBurton</dc:creator>
      <dc:date>2021-12-11T12:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259501#M19974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm looking forward to trying these suggestions on Monday!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 Aug 2017 05:00:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259501#M19974</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-18T05:00:07Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VB to Python, Help?</title>
      <link>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259502#M19975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Dan and Randy for helping me out!&amp;nbsp; It works now!&amp;nbsp; Another problem I had was that in shapefile form it would error "The field is not nullable".&amp;nbsp; I had to put it in a geodatabase before the field calculations would work.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Aug 2017 15:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vb-to-python-help/m-p/259502#M19975</guid>
      <dc:creator>TomMagdaleno</dc:creator>
      <dc:date>2017-08-22T15:12:26Z</dc:date>
    </item>
  </channel>
</rss>

