<?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: fnmatch or re? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/fnmatch-or-re/m-p/525019#M41146</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't check the rest of the code, but you could also use something simple as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14244568216682145" jivemacro_uid="_14244568216682145"&gt;&lt;P&gt;if type == "POLYGON" and "OLYGON" in name:&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, next time, please use syntax highlighting for your code (see: &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt; )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Feb 2015 18:27:44 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2015-02-20T18:27:44Z</dc:date>
    <item>
      <title>fnmatch or re?</title>
      <link>https://community.esri.com/t5/python-questions/fnmatch-or-re/m-p/525018#M41145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a dynamic coded script that runs as a tool. It utilizes&amp;nbsp; arcpy.mapping to add some files to an existing template and then update the layer's symbology and name. I want to be able to differentiate between a couple different layers that have&amp;nbsp; the same geometry but different names. For example, there could be a Polyline file for a Assignment Break, as well as a Polyline file for a fire line file. This is the code that I have input so far (it isn't working).&lt;/P&gt;&lt;P&gt;code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;shapesList = arcpy.mapping.ListLayers(mxd_Update, "*_lyr", mainDataFrame_Update)&lt;/P&gt;&lt;P&gt;for shapes in shapesList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; type = arcpy.Describe(shapes).shapetype.upper()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = arcpy.Describe(shapes).name.upper()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*OLYGON*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_perimeter)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(shapes, "NEW_SELECTION")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mainDataFrame_Update.zoomToSelectedFeatures()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(shapes, "CLEAR_SELECTION")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Fire Perimeter"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*NTENSE*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, intense_heat)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Intense Heat"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*CATTERED*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, scatter_heat)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Scattered Heat"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POLYLINE" and name== fnmatch.fnmatch(shapes, "*SSIGNMENT*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, assign_break)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Assignment Break"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POLYLINE" and name== fnmatch.fnmatch(shapes, "*IRE*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_line)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Fire Lines"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POINT" and name== fnmatch.fnmatch(shapes, "*OINTS*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_point)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Fire Points"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if type== "POINT" and name== fnmatch.fnmatch(shapes, "*SOLATED*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, iso_heat)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; shapes.name = "Isolated Heat"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "no go fo sho tho"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A couple of basic questions... you can't use two (*) to grab a group of text from the middle of a string, correct? I can't really get my head wrapped around how I would use the m. functions in re to get this done... and I also can't use fnmatch because it isn't a filename, correct? Either way, I'm in over my head on this little bit&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Feb 2015 17:47:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fnmatch-or-re/m-p/525018#M41145</guid>
      <dc:creator>ToddHowell</dc:creator>
      <dc:date>2015-02-20T17:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: fnmatch or re?</title>
      <link>https://community.esri.com/t5/python-questions/fnmatch-or-re/m-p/525019#M41146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I didn't check the rest of the code, but you could also use something simple as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14244568216682145" jivemacro_uid="_14244568216682145"&gt;&lt;P&gt;if type == "POLYGON" and "OLYGON" in name:&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, next time, please use syntax highlighting for your code (see: &lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt; )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Feb 2015 18:27:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/fnmatch-or-re/m-p/525019#M41146</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-02-20T18:27:44Z</dc:date>
    </item>
  </channel>
</rss>

