
84
|
Python Pocket Reference
X.__dict__
Dictionary used to store object X’s writable attributes.
I.__methods__
List of instance object I’s methods (name strings); it is
available on many built-in types.
*
I.__members__
List of instance object I’s data attributes (name strings);
it is available on many built-in types.
I.__class__
Class object from which instance I was generated. In
Version 2.2, this also applies to object types; most
objects will have a
__class__ attribute (e.g., [].__class_
_
== list == type([])).
C.__bases__
Tuple of class C’s base classes, as listed in C’s class state-
ment header.
X.__name__
Object X’s name as a string; for classes, the name in the
statement header; for modules, the name as used in
imports, or
"__main__" for the module at the top level of
a program (e.g., the main file run to launch a program).
Built-in Modules
Built-in modules are always available but must be imported
to be used in client modules. To access them, use one of
these formats:
•
import module, and fetch attribute names (module.name)
•
from module import name, and use module names unquali-
fied (
name)
•
from module import *, and use module names unqualified
(
name)
* _methods__ and __members__ are deprecated since Version 2.2; use the
built-in dir() function instead.