<?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 Syntax Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/syntax-error/m-p/519859#M40730</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm getting the following error with my code which is generated in excel using a VB script. I am really confused as to what's triggering it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Parsing error &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid token (line 16)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
lyr = arcpy.mapping.Layer("EPREC_SEQ")
lyr_1 = arcpy.mapping.Layer("Polls")
df = arcpy.mapping.ListDataFrames(mxd, "2012-06-05")[0]
lyr.definitionQuery = '"CONSNUM" = 135080 or "CONSNUM" = 135220'
lyr_1.definitionQuery = '"CONSNUM_1" = 135080 or "CONSNUM_1" = 135220'
df.extent = lyr.getExtent(True)
var_text = 0176
element_name = "map_ID" 
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", element_name): 
 if elm.name == element_name:
&amp;nbsp; elm.text = (var_text)
arcpy.RefreshActiveView()
arcpy.mapping.PrintMap (mxd)
var_text = 0184
element_name = "map_ID" 
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", element_name): 
 if elm.name == element_name:
&amp;nbsp; elm.text = (var_text)
arcpy.RefreshActiveView()
arcpy.mapping.PrintMap (mxd)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error is strange because it's identical code to line 9 which goes through fine. I put in one line at a time and for some reason when I set my var_text to anything above 0177 and anything below 200 I get the error, otherwise the code works fine. Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:40:23 GMT</pubDate>
    <dc:creator>JoelMadero</dc:creator>
    <dc:date>2021-12-11T22:40:23Z</dc:date>
    <item>
      <title>Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error/m-p/519859#M40730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm getting the following error with my code which is generated in excel using a VB script. I am really confused as to what's triggering it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Parsing error &amp;lt;type 'exceptions.SyntaxError'&amp;gt;: invalid token (line 16)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
lyr = arcpy.mapping.Layer("EPREC_SEQ")
lyr_1 = arcpy.mapping.Layer("Polls")
df = arcpy.mapping.ListDataFrames(mxd, "2012-06-05")[0]
lyr.definitionQuery = '"CONSNUM" = 135080 or "CONSNUM" = 135220'
lyr_1.definitionQuery = '"CONSNUM_1" = 135080 or "CONSNUM_1" = 135220'
df.extent = lyr.getExtent(True)
var_text = 0176
element_name = "map_ID" 
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", element_name): 
 if elm.name == element_name:
&amp;nbsp; elm.text = (var_text)
arcpy.RefreshActiveView()
arcpy.mapping.PrintMap (mxd)
var_text = 0184
element_name = "map_ID" 
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", element_name): 
 if elm.name == element_name:
&amp;nbsp; elm.text = (var_text)
arcpy.RefreshActiveView()
arcpy.mapping.PrintMap (mxd)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The error is strange because it's identical code to line 9 which goes through fine. I put in one line at a time and for some reason when I set my var_text to anything above 0177 and anything below 200 I get the error, otherwise the code works fine. Any thoughts?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:40:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error/m-p/519859#M40730</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2021-12-11T22:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error/m-p/519860#M40731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to put your var_text in quotes so it knows it is a string, otherwise it is trying to write unicode or something funky.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var_text = "0176"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 17:57:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error/m-p/519860#M40731</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2012-05-16T17:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax Error</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error/m-p/519861#M40732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You need to put your var_text in quotes so it knows it is a string, otherwise it is trying to write unicode or something funky.&lt;BR /&gt;var_text = "0176"&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You seem to be the helper of helpers today. Thanks that did the trick. In my last script I never noticed this because var_text was always based on one formula but now it's in an if statement that makes it different depending on the number so I guess unicode screwed it up but problem solved&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 May 2012 18:13:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error/m-p/519861#M40732</guid>
      <dc:creator>JoelMadero</dc:creator>
      <dc:date>2012-05-16T18:13:49Z</dc:date>
    </item>
  </channel>
</rss>

