Built-in Attributes
Some objects export special attributes which are predefined by Python.
X.__dict__
Dictionary used to store object X’s writeable attributes.
I.__methods__
List of instance object I’s methods (name strings); available on many built-in types.
I.__members__
List of instance object I’s data attributes (name strings); available on many built-in types.
I.__class__
Class object from which instance I was generated.
C.__bases__
Tuple of class C’s base classes, as listed in C’s class statement header.
X.__name__
Object X’s name as a string; for classes, the name in the statement header; for modules, this name as used in imports (“__main__” if the module is run as a top-level program).
Get Python Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.