0

TL;DR

I want to create a package (in fact, a package and sub-packages) in python3.

From python3 docs

packages are just a special kind of module. Specifically, any module that contains a __path__ attribute is considered a package.

My question is, where and how do I define the __path__ attribute?

My problem

I have the following directory/file structure in a python3 setup.

root_dir
├── migrate
    └── lib
        ├── __init__.py
        ├── database.py
        └── migrate.py

How do I turn migrate directory into a package, to be able to run

python -m migrate.lib.migrate

from inside the root_dir. I know that adding an __init__.py inside migrate directory will suffice to execute the above. But I wish to know understand more about the __path__ attribute.

satvik.t
  • 423
  • 4
  • 19

0 Answers0