Initializing a module

Importing a module for the first time in a particular program, or in interactive mode, causes Python to perform a series of actions called initializing the module. Here's how initializing works:

1. Python creates a module namespace that stores the names defined in the module.

2. Python runs the code in the module.

3. Python stores the name of the module in the local namespace.

TECHNICAL Initializing happens only the first time the module is imported. If you STUFF import the module again, the module code doesn't run, but the import updates the current namespace.

Was this article helpful?

0 0

Post a comment