Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 1.18 KB

structure.md

File metadata and controls

40 lines (32 loc) · 1.18 KB

structure of project "hello":

hello/
./
├── LICENSE
├── README.md
├── config
│   ├── app-dev.yaml
│   └── app.yaml
├── bin
│   └── start.sh
├── hello
│   └── world.py
├── docs
├── pyproject.toml
└── tests
    └── world_tests.py

init.py Best Practices

init.py files are used to initialize Python packages. They are executed when the package is first imported. init_.py files can be used to set up global variables, define functions and classes, and run code.

While init.py files are not required, they are often used to customize the behavior of a package.

  1. Use init.py to control what is imported by from module import *
  2. Use all to control what is imported by from package import *
  3. Use version for version numbering
  4. Use logging in init.py
  5. Use init.py to define a consistent look and feel for your packages
  6. Use init.py to initialize the package level logger
  7. Use init.py to register entry points
  8. Use init.py to configure matplotlib
  9. Use init.py to load data files
  10. Use init.py to set default values for other modules