<?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: Why is this unicode? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473177#M36958</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;​I think you error message is coming from the addMessage line.&amp;nbsp; Try this instead&lt;/P&gt;&lt;P&gt;&lt;SPAN class="k" style="color: blue; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;ListLayers&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="s" style="color: #a31515; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;""&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;cadastralLayer&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;)[&lt;/SPAN&gt;&lt;SPAN class="mi" style="color: #666666; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;0&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;name&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;as shown in &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/listlayers.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/listlayers.htm"&gt;ListLayers—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;As Dan mentioned, you are setting the cadastralLayer variable to an object and need to grab a property, name in the sample above, to print for verification that it worked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;the help also has other code samples that may help.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 23 Sep 2015 14:06:39 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2015-09-23T14:06:39Z</dc:date>
    <item>
      <title>Why is this unicode?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473175#M36956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apologies, I understand this is a basic issue but it confuses me. I have a script tool which I am writing in python to work with a particular MXD. In this script tool I have the following lines of code to reference two layers in the MXD's TOC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;subjectLayer = arcpy.mapping.ListLayers(mxd,subjectlayerName)[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;subjectLayer.definitionQuery = ""&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;cadastralLayer = arcpy.mapping.ListLayers(mxd,"Cadastre")[0]&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;arcpy.AddMessage( cadastralLayer) #To test if layer is set correctly&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;cadastralLayer.definitionQuery = ""&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The subjectLayer object gets set correctly. This is chosen as a parameter in the tools UI. The definition query also gets set correctly.The cadastralLayer object gets populated also (AddMessage shows grouplayername\layername) but I get a "Script failure: 'unicode' object has no attribute 'definitionQuery'" error when it tries to set a definition query on it. This object is set by referencing the layer name in the TOC. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is why is one a unicode and the other a layer object as they were both referenced using ListLayers? How do I correctly reference layers in the TOC?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Sep 2015 07:42:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473175#M36956</guid>
      <dc:creator>GinoMellino</dc:creator>
      <dc:date>2015-09-23T07:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this unicode?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473176#M36957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unicode is the new String&lt;/P&gt;&lt;P&gt;u'formerly called a string'&amp;nbsp; Unicode notice the u&lt;/P&gt;&lt;P&gt;'old school string'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string/text&lt;/P&gt;&lt;P&gt;Unicode supports more symbol/language character sets than ASCII, most(?) programming languages now support full(ish) Unicode support:(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Funicode.org%2F" rel="nofollow" target="_blank"&gt;http://unicode.org/&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FUnicode" rel="nofollow" target="_blank"&gt;https://en.wikipedia.org/wiki/Unicode&lt;/A&gt;&lt;/P&gt;&lt;P&gt;so when they say Unicode does not support... read string does not support...&lt;/P&gt;&lt;P&gt;which means you are passing a string to the function instead of what it wants.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now to your immediate concern&lt;/P&gt;&lt;P&gt;ListLayers ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fdesktop.arcgis.com%2Fen%2Fdesktop%2Flatest%2Fanalyze%2Farcpy-mapping%2Flistlayers.htm" rel="nofollow" target="_blank"&gt;http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/listlayers.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;returns&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Returns a Python list of &lt;A class="xref" href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/layer-class.htm"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;Layer&lt;/SPAN&gt;&lt;/A&gt; objects that exist within a map document (&lt;SPAN class="usertext"&gt;.mxd&lt;/SPAN&gt;), a data frame within a map document, or layers within a layer (&lt;SPAN class="usertext"&gt;.lyr&lt;/SPAN&gt;) file.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN class="arcpyref"&gt;ListLayers always returns a Python list object even if only one layer is returned. In order to return a &lt;/SPAN&gt;&lt;SPAN class="arcpyref"&gt;Layer&lt;/SPAN&gt; object, an index value must be used on the list (e.g., &lt;SPAN class="usertext"&gt;lyr = arcpy.mapping.ListLayers(mxd)[0]).&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN class="usertext"&gt;For&lt;/SPAN&gt; loops on a list provide an easy mechanism to iterate through each item in a list (e.g., &lt;SPAN class="usertext"&gt;for lyr in arcpy.mapping.ListLayers(mxd):).&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;So I suspect that in one instance, your code is returning the layer name (in Unicode) and in the other it is returning a layer object ( name? object?&amp;nbsp; not the same... an apple is only an apple only in English (ie pomme ... French))&lt;/P&gt;&lt;P&gt;So make sure you know whether you want the object... so you can access its properties ... or just the objects name&lt;/P&gt;&lt;P&gt;If this isn't the case ... never mind &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Sep 2015 09:04:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473176#M36957</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-09-23T09:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is this unicode?</title>
      <link>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473177#M36958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;​I think you error message is coming from the addMessage line.&amp;nbsp; Try this instead&lt;/P&gt;&lt;P&gt;&lt;SPAN class="k" style="color: blue; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;ListLayers&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="s" style="color: #a31515; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;""&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;cadastralLayer&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;)[&lt;/SPAN&gt;&lt;SPAN class="mi" style="color: #666666; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;0&lt;/SPAN&gt;&lt;SPAN class="p" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="o" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;name&lt;/SPAN&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt; &lt;/SPAN&gt;&lt;SPAN class="n" style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;as shown in &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/listlayers.htm" title="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-mapping/listlayers.htm"&gt;ListLayers—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;As Dan mentioned, you are setting the cadastralLayer variable to an object and need to grab a property, name in the sample above, to print for verification that it worked.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; font-family: Consolas, 'Andale Mono', 'Lucida Console', Monaco, 'Courier New', Courier, monospace; font-size: 12px; background-color: #fafafa;"&gt;the help also has other code samples that may help.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Sep 2015 14:06:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-is-this-unicode/m-p/473177#M36958</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-09-23T14:06:39Z</dc:date>
    </item>
  </channel>
</rss>

