First page Back Continue Last page Overview Graphics

More on Modules

Usually, modules contain functions, but there can be statements as well. These statements are used to initialize the module. They are only executed once, when the module is imported.

A module has a private symbol table, which is used as the global symbol table by all functions defined in the module.

This way global variables of a module can't accidentally clash with a user’s global variables.

Global variables of a module can be accessed with the same notation as functions, i.e.

modname.name

A module can import other modules. It is customary to place all import statements at the beginning of a module/script.