I wrote a python program which I call with arguments from console. As the functionality grew, so did the amount of code that is now all nested in one single file.
I know that there are python modules and packages which I could create in order to outsource the functions I wrote. But is this really the python way of doing things?
How would the folder structure look like? Something like
prog
__init__.py
module1.py
module2.py
prog.py
where prog (a directory or python package) and prog.py share the same directory?
That’s a good solution, thought your modules should be stored in a package not called like your main module. This would be prone to conflict between module and package name.
This could be
resources,libor anything, but please, notprog, as you already have a module namedprog.py; otherwise, how would you know the result ofimport prog?Note: from what I can see in my Python 2.6 install, with the structure and names you propose, you get no error message, but cannot access to
prog.pycontent.