diff options
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r-- | Lib/inspect.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py index 4baebe0c6f..a2ea7390bd 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -78,6 +78,16 @@ def ismethoddescriptor(object): and not isfunction(object) and not isclass(object)) +def isdatadescriptor(object): + """Return true if the object is a data descriptor. + + Data descriptors have both a __get__ and a __set__ attribute. Examples are + properties (defined in Python) and getsets and members (defined in C). + Typically, data descriptors will also have __name__ and __doc__ attributes + (properties, getsets, and members have both of these attributes), but this + is not guaranteed.""" + return (hasattr(object, "__set__") and hasattr(object, "__get__")) + def isfunction(object): """Return true if the object is a user-defined function. |