|  | 
| 6 | 6 | 
 | 
| 7 | 7 | Here are some of the useful functions provided by this module: | 
| 8 | 8 | 
 | 
| 9 |  | -    ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(), | 
| 10 |  | -        isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(), | 
| 11 |  | -        isroutine() - check object types | 
|  | 9 | +    ismodule(), isclass(), ismethod(), ispackage(), isfunction(), | 
|  | 10 | +        isgeneratorfunction(), isgenerator(), istraceback(), isframe(), | 
|  | 11 | +        iscode(), isbuiltin(), isroutine() - check object types | 
| 12 | 12 |     getmembers() - get members of an object that satisfy a given condition | 
| 13 | 13 | 
 | 
| 14 | 14 |     getfile(), getsourcefile(), getsource() - find an object's source code | 
|  | 
| 128 | 128 |     "ismethoddescriptor", | 
| 129 | 129 |     "ismethodwrapper", | 
| 130 | 130 |     "ismodule", | 
|  | 131 | +    "ispackage", | 
| 131 | 132 |     "isroutine", | 
| 132 | 133 |     "istraceback", | 
| 133 | 134 |     "markcoroutinefunction", | 
| @@ -186,6 +187,10 @@ def ismethod(object): | 
| 186 | 187 |     """Return true if the object is an instance method.""" | 
| 187 | 188 |     return isinstance(object, types.MethodType) | 
| 188 | 189 | 
 | 
|  | 190 | +def ispackage(object): | 
|  | 191 | +    """Return true if the object is a package.""" | 
|  | 192 | +    return ismodule(object) and hasattr(object, "__path__") | 
|  | 193 | + | 
| 189 | 194 | def ismethoddescriptor(object): | 
| 190 | 195 |     """Return true if the object is a method descriptor. | 
| 191 | 196 | 
 | 
|  | 
0 commit comments