<?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: hasattr(layer, &amp;quot;dataSource&amp;quot;) gives error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071586#M61465</link>
    <description>&lt;P&gt;Yes I got the error with ArcPro version 2.8.0.&lt;/P&gt;&lt;P&gt;I agree with you, I think it is a bug with the function.&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 17:14:03 GMT</pubDate>
    <dc:creator>NABAZGHARIBMOHAMMED</dc:creator>
    <dc:date>2021-06-23T17:14:03Z</dc:date>
    <item>
      <title>hasattr(layer, "dataSource") gives error</title>
      <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071401#M61456</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to iterate over all layers in a map to see the datasources, and as it is recommended it is good to see&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if hasattr(layer, "dataSource"):
     pass&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if the layer has attribute dataSource, but the problem is on basemap, it givers an error which is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;NameError: The attribute 'dataSource' is not supported on this instance of Layer.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I do not understand this errors, because it should skip the basemap because it does not have dataSource.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is anyone has any explanation for this issue?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 11:26:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071401#M61456</guid>
      <dc:creator>NABAZGHARIBMOHAMMED</dc:creator>
      <dc:date>2021-06-23T11:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: hasattr(layer, "dataSource") gives error</title>
      <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071461#M61459</link>
      <description>&lt;P&gt;Hi, how is your layer derived? Can you do a describe on the layer then use hasattr?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 13:36:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071461#M61459</guid>
      <dc:creator>VictorTey</dc:creator>
      <dc:date>2021-06-23T13:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: hasattr(layer, "dataSource") gives error</title>
      <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071529#M61462</link>
      <description>&lt;P&gt;I assume you are talking about Pro and not ArcMap here.&amp;nbsp; If so, the explanation is, it's a defect.&amp;nbsp; I logged a defect over a year ago for likely what is the same issue you are dealing with, but they have set it low priority, so I am not expecting them to address it any time soon.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;STRONG&gt;#BUG-000128367&lt;/STRONG&gt; Using the Python method hasattr() produces different error messages when used in ArcMap (10.7.1) versus ArcGIS Pro (2.5 Beta)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 23 Jun 2021 15:44:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071529#M61462</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-06-23T15:44:03Z</dc:date>
    </item>
    <item>
      <title>Re: hasattr(layer, "dataSource") gives error</title>
      <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071586#M61465</link>
      <description>&lt;P&gt;Yes I got the error with ArcPro version 2.8.0.&lt;/P&gt;&lt;P&gt;I agree with you, I think it is a bug with the function.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 17:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071586#M61465</guid>
      <dc:creator>NABAZGHARIBMOHAMMED</dc:creator>
      <dc:date>2021-06-23T17:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: hasattr(layer, "dataSource") gives error</title>
      <link>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071588#M61466</link>
      <description>&lt;P&gt;I tried to use Describe, but it says&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;data_source_list=[]
'''
I have several maps, I want to iterate over all layers.
'''
for map_ in this_project.listMaps(): 
    for layer in map_.listLayers():
        desc=arcpy.Describe(layer)
        if hasattr(desc, "dataSource"):
            if not desc.dataSource in data_source_list:
                pass
                '''data_spurce_list.append(desc)'''

'''out put'''
RuntimeError: Object: Describe input value is not valid type&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like describe does not accept layer.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 17:19:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hasattr-layer-quot-datasource-quot-gives-error/m-p/1071588#M61466</guid>
      <dc:creator>NABAZGHARIBMOHAMMED</dc:creator>
      <dc:date>2021-06-23T17:19:45Z</dc:date>
    </item>
  </channel>
</rss>

