<?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: python syntax error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398642#M31451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; return pdir + ' ' + sname + ' ' typ &amp;nbsp;&lt;/P&gt;&lt;P&gt;you are missing a + before typ &amp;nbsp;and if typ is numeric it should be str(typ)&lt;/P&gt;&lt;P&gt;better&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"{} {} {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdir&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sname&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; typ&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;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 Dec 2016 19:55:36 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2016-12-13T19:55:36Z</dc:date>
    <item>
      <title>python syntax error</title>
      <link>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398641#M31450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm having a bit of trouble figuring out what is wrong with this script. I am trying to tell it "if there is a direction in the pdir/sdir field, concatenate the string into the field, otherwise just print the sname + typ". It says the syntax error is on line 3. Thanks.&lt;/P&gt;&lt;P&gt;def reclass(pdir,sdir,typ,sname):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (pdir == 'N'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return pdir + ' ' + sname + ' ' typ&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (pdir == 'S'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return pdir + ' ' + sname + ' ' typ&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (pdir == 'E'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return pdir + ' ' + sname + ' ' typ&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (pdir == 'W'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return pdir + ' ' + sname + ' ' typ&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (sdir == 'N'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sname + ' ' typ + ' ' + sdir&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (sdir == 'S'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sname + ' ' typ + ' ' + sdir&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (sdir == 'E'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sname + ' ' typ + ' ' + sdir&lt;BR /&gt;&amp;nbsp; &amp;nbsp; elif (sdir == 'W'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sname + ' ' typ + ' ' + sdir&lt;BR /&gt;&amp;nbsp; &amp;nbsp; else:&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return sname + ' ' + typ&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 19:50:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398641#M31450</guid>
      <dc:creator>MatthewUpchurch1</dc:creator>
      <dc:date>2016-12-13T19:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: python syntax error</title>
      <link>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398642#M31451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; return pdir + ' ' + sname + ' ' typ &amp;nbsp;&lt;/P&gt;&lt;P&gt;you are missing a + before typ &amp;nbsp;and if typ is numeric it should be str(typ)&lt;/P&gt;&lt;P&gt;better&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;&lt;SPAN class="string token"&gt;"{} {} {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdir&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sname&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; typ&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 19:55:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398642#M31451</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-12-13T19:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: python syntax error</title>
      <link>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398643#M31452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/3116"&gt;Dan Patterson&lt;/A&gt;! Amateur mistake lol. How would I use the .format() in the field calculator though?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 20:04:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398643#M31452</guid>
      <dc:creator>MatthewUpchurch1</dc:creator>
      <dc:date>2016-12-13T20:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: python syntax error</title>
      <link>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398644#M31453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;just replace all your&amp;nbsp;&lt;/P&gt;&lt;P&gt;return ... your lines where you will forget the plus or space &amp;nbsp; &amp;nbsp;..... with&lt;/P&gt;&lt;P&gt;return &amp;nbsp;...my line&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;return &amp;nbsp;.... modify my line 1 to reflect your new order for N, S, E and W it&lt;/P&gt;&lt;P&gt;ie sname, typ, sdir&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;my format line replaces the { } with the contents of the values in the format side. since they are in order they will fill those brackets with the values... Note, that I put a space inbetween them... you could use commas or whatever in between them. &amp;nbsp;The trick is &amp;nbsp;the values are converted to strings automatically so there is no need for str ing anything. &amp;nbsp;and it will return a string as output&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 Dec 2016 20:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-syntax-error/m-p/398644#M31453</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-12-13T20:10:35Z</dc:date>
    </item>
  </channel>
</rss>

