I currently have a larger scale project than I normally attempt, in that I'm at the point where it is more convenient to split up my code base into multiple files.
I currently have my file system arrayed as such:
src/
main.py
tools/
__init__.py
widgets.py
I would like to add a new file about.py to the src directory such that:
src/
about.py
main.py
tools/
__init__.py
widgets.py
And where about.py is accessable by both main.py and tools/__init__.py.
How would I best go about doing this, and how would I organise the entry point to the application?
Response from @velvet quartz:
Best to use a unique project name for your package
So you have
project-name/src/project_name/__init__.py
And
project-name/src/project_name/__main__.py
And then you can run it withpython -m project_name
Then relative imports will work
@velvet quartz I'm sorry I didn't respond to this, I somehow forgot I made this post. I have a few more questions about this project. Some further help would be greatly appreciated!
-
I've been told elsewhere that it's bad practice to use relative imports from a parent directory, is that the case or should I still be fine?
-
And, were I to build this with PyInstaller or similar, how would I go about that considering the entry point is a directory?