unit testing - How should I organize Python source code? -
My first project is a queue that runs a command line experiment in multiple threads. I am starting to get a very long main.py
file, and I want to break it. In general, I'm looking for: How do Python programmers organize multiple source files? Is there any special structure that works for you?
My specific questions include:
It's great for something that you want to start with because it contains details of organizing large python code base.
If you come here from Google and are trying to figure out how to split a large source file into multiple, more manageable files, I will briefly summarize the process.
Assume that you currently have everything in a fi, called main.py
:
- another in the same folder Create source file (for this example we call our
utils.py
) - In
the
main code
Add a line at the top:import utils
What it does conceptually is to create a new module called utils
another In the source file. You can still import it where it is necessary.
Comments
Post a Comment