mirror of
https://github.com/python/cpython.git
synced 2025-10-19 16:03:42 +00:00
gh-125633: Add function ispackage
to stdlib inspect
(#125634)
--------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
This commit is contained in:
parent
c51b56038b
commit
dad3453129
5 changed files with 37 additions and 6 deletions
|
@ -6,9 +6,9 @@
|
|||
|
||||
Here are some of the useful functions provided by this module:
|
||||
|
||||
ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),
|
||||
isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),
|
||||
isroutine() - check object types
|
||||
ismodule(), isclass(), ismethod(), ispackage(), isfunction(),
|
||||
isgeneratorfunction(), isgenerator(), istraceback(), isframe(),
|
||||
iscode(), isbuiltin(), isroutine() - check object types
|
||||
getmembers() - get members of an object that satisfy a given condition
|
||||
|
||||
getfile(), getsourcefile(), getsource() - find an object's source code
|
||||
|
@ -128,6 +128,7 @@
|
|||
"ismethoddescriptor",
|
||||
"ismethodwrapper",
|
||||
"ismodule",
|
||||
"ispackage",
|
||||
"isroutine",
|
||||
"istraceback",
|
||||
"markcoroutinefunction",
|
||||
|
@ -186,6 +187,10 @@ def ismethod(object):
|
|||
"""Return true if the object is an instance method."""
|
||||
return isinstance(object, types.MethodType)
|
||||
|
||||
def ispackage(object):
|
||||
"""Return true if the object is a package."""
|
||||
return ismodule(object) and hasattr(object, "__path__")
|
||||
|
||||
def ismethoddescriptor(object):
|
||||
"""Return true if the object is a method descriptor.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue