Modern Python Projects Transcripts
Chapter: Managing Python project
Lecture: Medium projects
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
As you add more features to your project, the single Python file starts growing, so, at some point you will have to split it into separate files.
0:10
You might still use one main file, but you move all the helper functions into separate files, and store them inside the folder
0:17
like here. Or maybe you move all the Python files inside one folder like here on the right, although as the number of test grows,
0:25
you will probably split your tests into separate files, and move them inside the folder called
0:30
tests. So, now you're Project looks more like one of those two options. They're both quite similar, so let's discuss the project structure on the left.
0:39
Now we have two new folders, medium and tests, medium contains all additional Python files.
0:46
You will usually name this folder in the same way as the name of your application
0:49
So, if my application is called medium, because this is a medium sized project, then this folder is also called Medium.
0:57
We still have a main.py file that we used to start our application but this main.py imports additional functions from files inside the medium directory
1:08
I have also moved all the tests inside the directory called tests. And here I have split all the tests into separate files,
1:16
depending on what they are testing. As you can see, we have a nice separation.
1:21
We have the main folder that contains our main Python file and all the additional
1:26
files for our project. We have the medium folder that contains all Python files related
1:32
to our application and finally, tests that contain all the tests. Everything has its own place.