How to get all attributes and methods in python object

Viewed 47

I encountered such method called __subclasscheck__, however I could not find it with dir(object) or inspect.getmembers(object), as it shows below.

Python 3.7.6 (default, Jan  8 2020, 13:42:34)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> dir(object)
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']
>>> import inspect
>>> [m for m in inspect.getmembers(object) if m[0].find("subclass") >= 0]
[('__init_subclass__', <built-in method __init_subclass__ of type object at 0x10d9903d8>), ('__subclasshook__', <built-in method __subclasshook__ of type object at 0x10d9903d8>)]
>>> object.__subclasscheck__
<built-in method __subclasscheck__ of type object at 0x10d9903d8>

so I wonder whether there exists a way to list literally all attributes and methods in python object.

0 Answers
Related