Open harshraj22 opened 2 years ago
Instead of using sys.path.append
or modifying PYTHONPATH
to include files from other directory, one should prefer using setup.py
: python3 setup.py develop
To uninstall: python3 setup.py develop --uninstall
1
Use:
from setuptools import setup, find_packages
setup(package_dir={'': 'src'})
in case of directory structure like:
.
├── setup.py
├── src
│ └── package
│ └── utils.py
│ └── __init__.py
└── tests
└── test_module.py
and the test_module.py
can contain imports like:
from package.utils import utility_func
Use a logging configuration to set a system wide logging instead of repeating logger's code in each file
A good answer to using multiple loggers across files here
pycon talk about logging
Could have used meta class to enforce the existance of mode
property in the subclasses, rather than having a default on in the base class. The current used approach violates design principle.
Add a wiki page on structuring Python Projects. Adding details like limiting number of
.py
files in the top directory, separating concerns across directories, preferring to change python search path to import from sibling directories etcreferences: [1], [2]