Create a main.py
File for the Core of the Application
#3
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Potlatch-Loggers/ComputerKeeper#3
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Every good project needs a place to start; right? Software is no different.
All software has to have some starting place. Windows has the "Start Button," PC games have Steam, so on... and so on...
Our application has to have some starting file; the place where other things start from. The "Pythonic" way for an app to begin is with either an
app.py
ormain.py
file that can be executed, starting the program. Sure, we can break out other files to support the main one (in fact, we'll try to do this whenever it makes sense), but we still need a robust place to start.Our
main.py
file should include the following:What's a
main
function?Main functions are where the body of code is executed from. Generally, they look something like this:
What's an entrypoint?
Entrypoints are the way that a program starts. We could consider this whole system as something that someone else might want to "import," or use elsewhere, right? So, we should
write our code in a way that it can be leveraged in the future.
Entrypoints allow us to run the main Python file, directly, but also skip running it if we'd rather import it somehow. They look something like this: