<?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 Code Assist!!! in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437949#M34405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perhaps you should check the documentation &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000021000000"&gt;here&lt;/A&gt;&lt;SPAN&gt;, it states that arcpy.Exists() takes "The name, path, or both of a feature class, table, dataset, layer, shapefile, workspace, or file to be checked for existence."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still don't understand what Taxlot is. &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;IF &lt;/STRONG&gt;&lt;SPAN&gt;it is a list of paths to, say, shapefiles, then it will work. If you are trying to check if features within a shapefile/feature class exist, then this is not the right tool for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you provide an example of Taxlot?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 20:25:45 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2013-07-16T20:25:45Z</dc:date>
    <item>
      <title>Python Code Assist!!!</title>
      <link>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437946#M34402</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to check for the existence of data within a particular attribute field in a given shapefile.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the code I'm working with (on model builder) which I know needs major debbuging...but I'm not sure how.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Expression&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;x("%Taxlot%", "%Workspace%")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Code Block&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;def x(Taxlot, Workspace):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.workspace = Workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(Taxlot):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "true"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "false"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Data type&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Boolean&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN style="font-style:italic;"&gt;The result I get when I run this piece is always "false", even when I think it's true :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: "Taxlot" is the name of the model parameter which accepts a list of values from the user.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The code is supposed to check these input values against "Workspace", which is the name of the shapefile that holds the attribute table where the field of interest is.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This might be a little confusing but I can clarify for anyone that may have a suggestion or actual code to achieve this.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you much!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Shiko&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Jul 2013 21:59:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437946#M34402</guid>
      <dc:creator>ShikoNjuno</dc:creator>
      <dc:date>2013-07-15T21:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python Code Assist!!!</title>
      <link>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437947#M34403</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;First things first, you do not need this line in field calculator or calculate value codeblocks:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is to do with your Taxlot variable, and there are two issues with it:&lt;/SPAN&gt;&lt;BR /&gt;&lt;OL&gt;&lt;BR /&gt;&lt;LI&gt;you convert it to a string in the &lt;STRONG&gt;Expression&lt;/STRONG&gt;, as it is wrapped in quotes ("). If it is supposed to be a string, that is fine, but in your case it should be kept as a list. See below.&lt;/LI&gt;&lt;BR /&gt;&lt;LI&gt;arcpy.Exists() checks that something like a feature class or shapefile exists, you cannot just pass it a list. &lt;STRONG&gt;If&lt;/STRONG&gt; it is a list of feature class paths, I have given some corrected code below.&lt;/LI&gt;&lt;BR /&gt;&lt;/OL&gt;&lt;STRONG&gt;Expression&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;x(%Taxlot%, %Workspace%)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that I took the quotes away from both variables. Workspace is already a string, so it doesn't need the quotes. The only time you need quotes should be when you are changing types, i.e., if you had a number, but you wanted Python to deal with it as a string value.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Code block&lt;/STRONG&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;def x(Taxlot, Workspace): &amp;nbsp; arcpy.env.workspace = Workspace &amp;nbsp; if all in [arcpy.Exists(t) for t in Taxlot]: &amp;nbsp;&amp;nbsp;&amp;nbsp; return True &amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp; return False&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This uses something called a list comprehension (a &lt;/SPAN&gt;&lt;STRONG&gt;for&lt;/STRONG&gt;&lt;SPAN&gt; statement within list brackets) that builds the list on the fly, it basically says if all the elements of the list exist, return True, otherwise return False.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 04:26:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437947#M34403</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-07-16T04:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Code Assist!!!</title>
      <link>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437948#M34404</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Awesome!!!!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you soooo much for taking the time to break it down like you did.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I do however have a question about the Exists function; what I want to do is process the list of taxlots that are in the file, rather than check if ALL list values are in the shapefile or not.This is what I'm getting from that piece of code.....is it possible to say &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; if in [arcpy.Exists(t) for t in Taxlot]:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;etc...??&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Oh and just to clarify....taxlot is a user-input list of strings. So the type is specified as such.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Stacy.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:20:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437948#M34404</guid>
      <dc:creator>ShikoNjuno</dc:creator>
      <dc:date>2013-07-16T14:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: Python Code Assist!!!</title>
      <link>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437949#M34405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Perhaps you should check the documentation &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000021000000"&gt;here&lt;/A&gt;&lt;SPAN&gt;, it states that arcpy.Exists() takes "The name, path, or both of a feature class, table, dataset, layer, shapefile, workspace, or file to be checked for existence."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I still don't understand what Taxlot is. &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;IF &lt;/STRONG&gt;&lt;SPAN&gt;it is a list of paths to, say, shapefiles, then it will work. If you are trying to check if features within a shapefile/feature class exist, then this is not the right tool for you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you provide an example of Taxlot?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 20:25:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-code-assist/m-p/437949#M34405</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2013-07-16T20:25:45Z</dc:date>
    </item>
  </channel>
</rss>

