3.11.1 Modules
The only special operation on a module is attribute access:
m.name , where m is a module and name
accesses a name defined in m's symbol table. Module attributes
can be assigned to. (Note that the import statement is not,
strictly speaking, an operation on a module object; import
foo does not require a module object named foo to exist,
rather it requires an (external) definition for a module named
foo somewhere.)
A special member of every module is __dict__.
This is the dictionary containing the module's symbol table.
Modifying this dictionary will actually change the module's symbol
table, but direct assignment to the __dict__ attribute is not
possible (you can write m.__dict__['a'] = 1 , which
defines m.a to be 1 , but you can't write
m.__dict__ = {} ). Modifying __dict__ directly
is not recommended.
Modules built into the interpreter are written like this:
<module 'sys' (built-in)> . If loaded from a file, they are
written as <module 'os' from
'/usr/local/lib/python2.5/os.pyc'> .
Release 2.5.2, documentation updated on 21st February, 2008.
See About this document... for information on suggesting changes.
|