Skip to content Skip to sidebar Skip to footer

Skip Over Levels Of A Directory When Importing Python Package

I've got a directory structure like: Folder_in_PYTHONPATH/ ├── Package1 │   ├── __init__.py │   ├── src │   │   ├── Class1.py │   │ �

Solution 1:

Add them into your packages' __init__.py files so they look like:

fromsrc import Class1
fromsrc import Class2

Have a look at the docs

I would recommend putting the *.py files in the top level folder of their package to get the import Package_1.Class1 behaviour you are after. The unit tests can stay in their own folder to keep them separate.

Post a Comment for "Skip Over Levels Of A Directory When Importing Python Package"