Return true if the object is a method descriptor. But not if ismethod() or isclass() or isfunction() are true. This is new in Python 2.2, and, for example, is true of int.__add__. An object passing this test has a __get__ attribute, but not a __set__ attribute or a __delete__ attri
(object)
| 194 | return ismodule(object) and hasattr(object, "__path__") |
| 195 | |
| 196 | def ismethoddescriptor(object): |
| 197 | """Return true if the object is a method descriptor. |
| 198 | |
| 199 | But not if ismethod() or isclass() or isfunction() are true. |
| 200 | |
| 201 | This is new in Python 2.2, and, for example, is true of int.__add__. |
| 202 | An object passing this test has a __get__ attribute, but not a |
| 203 | __set__ attribute or a __delete__ attribute. Beyond that, the set |
| 204 | of attributes varies; __name__ is usually sensible, and __doc__ |
| 205 | often is. |
| 206 | |
| 207 | Methods implemented via descriptors that also pass one of the other |
| 208 | tests return false from the ismethoddescriptor() test, simply because |
| 209 | the other tests promise more -- you can, e.g., count on having the |
| 210 | __func__ attribute (etc) when an object passes ismethod().""" |
| 211 | if isclass(object) or ismethod(object) or isfunction(object): |
| 212 | # mutual exclusion |
| 213 | return False |
| 214 | tp = type(object) |
| 215 | return (hasattr(tp, "__get__") |
| 216 | and not hasattr(tp, "__set__") |
| 217 | and not hasattr(tp, "__delete__")) |
| 218 | |
| 219 | def isdatadescriptor(object): |
| 220 | """Return true if the object is a data descriptor. |
no test coverage detected
searching dependent graphs…