type-module
Modules
Modules are imported by the import statement. A module object has
a namespace implemented by a dictionary object (this is the dictionary
referenced by the func_globals attribute of functions defined in the
module). Attribute references are translated to lookups in this
dictionary, e.g., m.x is equivalent to m.__dict__["x"]. A
module object does not contain the code object used to initialize the
module (since it isn't needed once the initialization is done).
Attribute assignment updates the module's namespace dictionary, e.g., "m.x = 1" is equivalent to "m.__dict__["x"] = 1".
Special read-only attribute:
- __dict__ is the module's namespace as a dictionary object.
Predefined (writable) attributes:
- __name__ is the module's name.
- __doc__ is the module's documentation string, or None if unavailable.
- __file__ is the pathname of the file from which the module was loaded, if it was loaded from a file.
The __file__ attribute is not present for C modules that are statically linked into the interpreter; for extension modules loaded dynamically from a shared library, it is the pathname of the shared library file.
last updated 3 years ago by effbot #

Merge with text from the library reference:
effbot 3 years ago #