PyDocs

Nav

Python Runtime Services

isdatadescriptor

inspect

function (source)
  • isdatadescriptor(object)
Return true if the object is a data descriptor.

But not if ismethod(), isclass() or isfunction() is true.

Data descriptors have a __set__ or a __delete__ attribute.  Examples are
properties, getsets, and members.  For the latter two (defined only in C
extension modules) more specific tests are available as well:
isgetsetdescriptor() and ismemberdescriptor(), respectively.

Typically, data descriptors will also have __name__ and __doc__ attributes
(properties, getsets, and members have both of these attributes), but this
is not guaranteed.
Changed in 3.8
  • 3.8: This function now reports objects with only a __set__() method as being data descriptors (the presence of __get__() is no longer required for that). Moreover, objects with __delete__(), but not __set__(), are now properly recognized as data descriptors as well, which was not the case previously.
0 Examples
No examples for inspect/isdatadescriptor.
See Also
No see-alsos for inspect/isdatadescriptor
0 Notes
No notes for isdatadescriptor