The article Eric pointed to is awesome because it covers details of organising large Python code bases.
If you've landed here from Google and are trying to find out how to split one large source file into multiple, more manageable, files I'll summarise the process briefly.
Assume you currently have everything in a file called main.py
:
- Create another source file in the same folder (let's call ours
utils.py
for this example)
- Move whatever classes, functions, statements, etc you need from
main.py
into utils.py
- In
main.py
add a single line at the top: import utils
Conceptually what this does is to create a new module called utils
in another source file. You can then import it wherever it's needed.