Feb-02-2020, 08:46 PM
The import would be like this:
This can be done with
Also for Python 2.7 so most have
>>> from ProjectDir.utils.helper import XYZ >>> obj = XYZ('Kent') >>> obj.name 'Kent'I do not like long import,so many/most of the time i lift sub-modules up.
This can be done with
__init__.py
in the top level folder also under ProjectDir.__init__.py
from .utils.helper import XYZNow can import like this.
>>> from ProjectDir import XYZ >>> >>> obj = XYZ('Kent') >>> obj.name 'Kent'As mention do not use Python 2.7 anymore
Also for Python 2.7 so most have
__init__.py
blank,in all folder for it to be a package.