Basic importing question
lists at cheimes.de
Wed Aug 20 14:51:36 CEST 2008
Bruno Desthuilliers wrote:
> As the name imply, built-in modules are built in the interpreter - IOW,
> they are part of the interpreter *exposed* as modules. Unless you
> have a taste for gory implementation details, just don't worry about this.
> Other "ordinary" modules need of course to be executed once when first
> loaded - IOW, the first time they are imported. All statements at the
> top-level of the module are then sequentially executed, so that any
> relevant object (functions, classes, whatever) are created and bound in
> the module's namespace.
Builtin modules like thread, signal etc. as well as C extensions like
socket have an initialization function. The initialization function is
called during the first import of a module. It creates the module object
and assigns objects to its __dict__ attribute.
Builtin modules are statically linked into the Python executable /
library while normal C extensions are shared libraries. Some modules are
builtins because they are required during boot strapping. It's possible
to embed most C modules into the core.
More information about the Python-list