Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Improved the code
  • Loading branch information
Xiaokang2022 committed Oct 17, 2024
commit ef7eebd47db61e8c76c146cf2c5c7f6b7ec80ba4
4 changes: 1 addition & 3 deletions Lib/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ def ismethod(object):

def ispackage(object):
"""Return true if the object is a package."""
if ismodule(object) and object.__spec__ is not None:
return object.__spec__.parent == object.__spec__.name
return False
return ismodule(object) and hasattr(object, "__path__")

def ismethoddescriptor(object):
"""Return true if the object is a method descriptor.
Expand Down