Python
Modules and the import Statement
A module is a .py file. import runs it once, caches it, and binds a name. Every import form is a variation on those three steps.
Writing and importing modules, import forms and aliases, __name__ and __main__, the module search path, packages and __init__.py.
3 notes
A module is a .py file. import runs it once, caches it, and binds a name. Every import form is a variation on those three steps.
Every module has a __name__. It is "__main__" when the file is run directly and the module name when it is imported, which is what the main guard test...
A package is a directory of modules. __init__.py marks it and defines its public face, and relative imports let modules inside it find each other.