<?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 labelclasses expression help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403909#M31804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as an FYI, Geoff, I don't believe you need any of those \n.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2015 01:56:16 GMT</pubDate>
    <dc:creator>SepheFox</dc:creator>
    <dc:date>2015-06-12T01:56:16Z</dc:date>
    <item>
      <title>Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403906#M31801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working with many shapefiles that all need to be symbolized and labeled the same way.&amp;nbsp; I've gotten symbol layer matching to work, but I've having difficulty with the labels, particularly with the expression working.&amp;nbsp; My expressions works fine loading the text file from the layer properties window, but not through the Python console.&amp;nbsp; My expression uses the Advanced Python dialogue box.&lt;/P&gt;&lt;P&gt;Here is my code so far.&amp;nbsp; It's copied and pasted from the expression window and wrapped in triple quotes, but it does not end up labeling.&amp;nbsp; Is there a particular way to enter the expression?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("Current")# Define mxd to current file.&lt;/P&gt;&lt;P&gt;inputData0 = "AM_Bourbonnais_Pkwy_WB_LINE_Spring_2015"&lt;/P&gt;&lt;P&gt;mapLyr0 = arcpy.mapping.ListLayers(mxd, inputData0) [0]&lt;/P&gt;&lt;P&gt;lFunc = """def FindLabel ( [Speed] ):\n&lt;/P&gt;&lt;P&gt;&amp;nbsp; label = str(round(float([Speed]),0))\n&lt;/P&gt;&lt;P&gt;&amp;nbsp; if label[1] == '.':\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; label = label[:1]\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; label = label + " MPH"\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return label\n&lt;/P&gt;&lt;P&gt;&amp;nbsp; else:\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; label = label[:2]\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; label = label + " MPH"\n&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return label"""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mapLyr0.labelClasses[0].expression = lFunc&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 16:20:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403906#M31801</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2015-06-11T16:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403907#M31802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It appears I was having a refresh problem or something, because now it seems to work.&amp;nbsp; Strange.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 16:36:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403907#M31802</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2015-06-11T16:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403908#M31803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can &lt;A _jive_internal="true" href="https://community.esri.com/message/471715#471715"&gt;mark as assumed answered&lt;/A&gt; so people know you don't still need help. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2015 18:10:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403908#M31803</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-11T18:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403909#M31804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as an FYI, Geoff, I don't believe you need any of those \n.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 01:56:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403909#M31804</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-06-12T01:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403910#M31805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sephe.&amp;nbsp; I included them because when I look at the expression copied to the label's expression box, it's a single line of text.&amp;nbsp; I don't know how it gets interpreted to I included them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:16:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403910#M31805</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2015-06-15T16:16:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403911#M31806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried my script again today, and it doesn't want to work.&amp;nbsp; I think the problem is that layers are defaulted to using VBscript for the expression, but mine is Advanced Python.&amp;nbsp; If I run the script on a layer that has the default VBscript, it won't label properly.&amp;nbsp; If the layer is only set to Python, it doesn't label properly.&amp;nbsp; When I have the expression type set to Python and the advanced box checked, then it works.&amp;nbsp; Are there additional parameters to set the label expression type to Python and Advanced?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403911#M31806</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2015-06-15T16:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403912#M31807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looking at &lt;A href="http://resources.arcgis.com/en/help/main/10.1/00s3/00s30000002t000000.htm"&gt;the documentation&lt;/A&gt;, I don't see anything where you can explicitly specify which expression type to use.&lt;/P&gt;&lt;P&gt;It does give an example of printing the label class expression, so try that and see if it includes anything about which type it's using and adjust your format accordingly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:38:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403912#M31807</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-06-15T16:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403913#M31808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In the label expression box returns can be used to organize your label, but they don't effect the resulting label. The \n character is used to actually enforce a new line in your label text. The same is true for your python script--you can use a simple return to go to a new line, and \n is only needed if you want your label text to have a line break.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 16:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403913#M31808</guid>
      <dc:creator>SepheFox</dc:creator>
      <dc:date>2015-06-15T16:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403914#M31809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately it just outputs what I coded as the input.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jun 2015 17:37:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403914#M31809</guid>
      <dc:creator>GeoffOlson</dc:creator>
      <dc:date>2015-06-15T17:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python labelclasses expression help</title>
      <link>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403915#M31810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you ever find any resolution on this? I am running into the same issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jun 2015 13:45:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-labelclasses-expression-help/m-p/403915#M31810</guid>
      <dc:creator>JamesKelly2</dc:creator>
      <dc:date>2015-06-22T13:45:45Z</dc:date>
    </item>
  </channel>
</rss>

