- Modules are way to structure python program.
- A module would have set of related functionalities.
- Each python program file (.py file) is a module, which imports other modules (object) to use names (attributes) they define using object.attribute notation.
- All the top level names of a module are attributes, exported for use by the importer of this module.
- Filename of a module turns out to be an object name where it is imported.
- import re; statement imports all the names defined in module re.from statements can be used to import specific names from a module.
- Both the above statements finds, compiles and loads (if not yet loaded) the module.
- Python by default imports modules only once per file per process, when the very first import statement is encountered.
- With from statement, names can be directly used. module name is not required.
Python Modules
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment