Copyright (C) 2000-2012 |
GNU Info (python2.1-lib.info)ModulesModules ....... 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 (i.e., you can write `M.__dict__['a'] = 1', which defines `M.a' to be `1', but you can't write `M.__dict__ = {}'. 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.1/os.pyc'>'. automatically generated by info2www version 1.2.2.9 |