Defining Main Functions in Python: Summary
Congratulations! You now know how to create Python
Here’s what you covered:
Knowing the value of the
__name__variable is important to write code that serves the dual purpose of executable script and importable module.
__name__takes on different values depending on how you executed your Python file.
__name__will be equal to:
"__main__"when the file is executed from the command line or with
python -m(to execute a package’s
- The name of the module, if the module is being imported
- Python programmers have developed a set of best practices to use when you want to develop reusable code.
Now you’re ready to go write some awesome Python
main() function code!
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.
Comments & Discussion
Become a Member to join the conversation.