AnsweredAssumed Answered

How to Introspect a Describe "Object"

Question asked by tlaxson on Jun 22, 2017
Latest reply on Aug 8, 2017 by Dan_Patterson

Though the documentation refers to a "Describe object", it must be some sort of C class (apparently via the arcgisscripting.create function), instead of a Python class. The standard Python introspection methods don't turn up much information (see below).

 

If one wishes to summarize all the known info of a dataset, how might one dynamically identify which properties apply to the current instance--without writing a long series of if statements and/or going through all the potential properties?

 

For reference: given a variable named "desc" returned from a call to arcpy.Describe, here are the results of some inspection and introspection operations:

>>> type(desc)
<type 'geoprocessing describe data object'>

>>> dir(desc)
[]

>>> desc.__name__
'Describe Object'

>>> desc.__class__
Traceback (most recent call last): 
File "<interactive input>", line 1, in <module>
AttributeError: DescribeData: Method __class__ does not exist

>>> desc.__repr__
Traceback (most recent call last): 
File "<interactive input>", line 1, in <module>
AttributeError: DescribeData: Method __repr__ does not exist

>>> isinstance(desc, object)
True

>>> desc.__dict__
Traceback (most recent call last): 
File "<interactive input>", line 1, in <module>
AttributeError: DescribeData: Method __dict__ does not exist

>>> help(desc)
Help on geoprocessing describe data object object:
Describe Object = class geoprocessing describe data object(object)

>>> print(inspect.getmodule(desc))
None

>>> inspect.getclasstree(desc)
Traceback (most recent call last): 
File "<interactive input>", line 1, in <module> 
File "C:\Python27\ArcGISx6410.4\Lib\inspect.py", line 726, in getclasstree   
    for c in classes:
TypeError: 'geoprocessing describe data object' object is not iterable

>>> inspect.getmro(desc)
Traceback (most recent call last): 
File "<interactive input>", line 1, in <module> 
File "C:\Python27\ArcGISx6410.4\Lib\inspect.py", line 346, in getmro
    _searchbases(cls, result)
File "C:\Python27\ArcGISx6410.4\Lib\inspect.py", line 337, in _searchbases
    for base in cls.__bases__:
AttributeError: DescribeData: Method __bases__ does not exist

Outcomes