Packages
Package is directory with modules
Why do we need them?
For structuring modules for easier usage
How to create a package?
Create directory
Optional: Place a module
That's it...
Note: In Python 2 and Python 3 before 3.5 you required to place there special (maybe empty) file
__init__.py
In main.py
we can import presented packages/modules in the following ways:
If we need to import something in package's modules - it's better to use absolute import and specify path to needed module. It will be possible because entry point is main.py
and PYTHONPATH
will be set accordingly.
Last updated