<?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 Error 000989: Python Syntax Error in Copied Python Snippet in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589476#M46200</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having an issue with a simple python snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the background: I wanted to include an additional step in a nightly update script that replaces characters in a field that simply do not play nice with a web application that allows users to query the data.&amp;nbsp; These characters included angle brackets ("&amp;lt;" and "&amp;gt;") which I was trying to replace with "Less Than" and "Greater Than".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I was testing the Field Calculation, I finally got it to work the way I wanted to, and as I have done with so many other snippets, I simply copied the Python Snippet of the geoprocess, and pasted into my script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the snippet:&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("path/to/my/layer","field","RemoveBad( !field!)","PYTHON_9.3","def RemoveBad(x):/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;=', ' Less Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;=', ' Greater Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;', ' Less Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;', ' Greater Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('=', ' Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.strip()/n&amp;nbsp;&amp;nbsp; return x")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now in my script, I do have a log that reports geoprocessing errors, so when I run the script, I am getting the following:&lt;/P&gt;&lt;P&gt;Executing: CalculateField path\to\my\layer field RemoveBad( !field!) PYTHON_9.3 "def RemoveBad(x):/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;=', ' Less Than or Equal To ' )/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;=', ' Greater Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;', ' Less Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;', ' Greater Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('=', ' Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.strip()/n&amp;nbsp;&amp;nbsp; return x"&lt;/P&gt;&lt;P&gt;Start Time: Mon Aug 25 09:35:32 2014&lt;/P&gt;&lt;P&gt;Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 1)&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateField).&lt;/P&gt;&lt;P&gt;Failed at Mon Aug 25 09:35:32 2014 (Elapsed Time: 0.00 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I started combing through the script but I cannot find the issue, which leads me to believe it has something to do with the angle brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance in pointing out where the syntax error is occurring would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris B.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Aug 2014 14:58:01 GMT</pubDate>
    <dc:creator>ChristopherBlinn1</dc:creator>
    <dc:date>2014-08-25T14:58:01Z</dc:date>
    <item>
      <title>Error 000989: Python Syntax Error in Copied Python Snippet</title>
      <link>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589476#M46200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having an issue with a simple python snippet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's the background: I wanted to include an additional step in a nightly update script that replaces characters in a field that simply do not play nice with a web application that allows users to query the data.&amp;nbsp; These characters included angle brackets ("&amp;lt;" and "&amp;gt;") which I was trying to replace with "Less Than" and "Greater Than".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when I was testing the Field Calculation, I finally got it to work the way I wanted to, and as I have done with so many other snippets, I simply copied the Python Snippet of the geoprocess, and pasted into my script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the snippet:&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("path/to/my/layer","field","RemoveBad( !field!)","PYTHON_9.3","def RemoveBad(x):/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;=', ' Less Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;=', ' Greater Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;', ' Less Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;', ' Greater Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('=', ' Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.strip()/n&amp;nbsp;&amp;nbsp; return x")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now in my script, I do have a log that reports geoprocessing errors, so when I run the script, I am getting the following:&lt;/P&gt;&lt;P&gt;Executing: CalculateField path\to\my\layer field RemoveBad( !field!) PYTHON_9.3 "def RemoveBad(x):/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;=', ' Less Than or Equal To ' )/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;=', ' Greater Than or Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;lt;', ' Less Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('&amp;gt;', ' Greater Than ')/n&amp;nbsp;&amp;nbsp; x = x.replace('=', ' Equal To ')/n&amp;nbsp;&amp;nbsp; x = x.strip()/n&amp;nbsp;&amp;nbsp; return x"&lt;/P&gt;&lt;P&gt;Start Time: Mon Aug 25 09:35:32 2014&lt;/P&gt;&lt;P&gt;Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 1)&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateField).&lt;/P&gt;&lt;P&gt;Failed at Mon Aug 25 09:35:32 2014 (Elapsed Time: 0.00 seconds)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I started combing through the script but I cannot find the issue, which leads me to believe it has something to do with the angle brackets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any assistance in pointing out where the syntax error is occurring would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Chris B.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 14:58:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589476#M46200</guid>
      <dc:creator>ChristopherBlinn1</dc:creator>
      <dc:date>2014-08-25T14:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000989: Python Syntax Error in Copied Python Snippet</title>
      <link>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589477#M46201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It should be \n in the code snippet, not /n.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 16:19:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589477#M46201</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2014-08-25T16:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Error 000989: Python Syntax Error in Copied Python Snippet</title>
      <link>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589478#M46202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Indeed, I also received a few suggestions here:&amp;nbsp; &lt;A href="http://gis.stackexchange.com/questions/111644/python-syntax-error-when-running-python-snippet-of-successful-geoprocess" title="http://gis.stackexchange.com/questions/111644/python-syntax-error-when-running-python-snippet-of-successful-geoprocess"&gt;arcgis desktop - Python Syntax Error when running Python Snippet of successful geoprocess - Geographic Information Syste…&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your feedback!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Aug 2014 16:27:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-000989-python-syntax-error-in-copied-python/m-p/589478#M46202</guid>
      <dc:creator>ChristopherBlinn1</dc:creator>
      <dc:date>2014-08-25T16:27:20Z</dc:date>
    </item>
  </channel>
</rss>

