Best Practices for Python Main Functions
Now that you know the differences between how Python handles the various execution modes, it’s useful for you to know which best practices you can implement. You’ll learn about four best practices you can use to make sure that your code can serve a dual purpose:
- Put most code into a function or class.
__name__to control execution of your code.
- Create a function called
main()to contain the code you want to run.
- Call other functions from
Comments & Discussion
Become a Member to join the conversation.