Congratulations! You now know how to create Python main() functions.
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 withpython -m(to execute a package’s__main__.pyfile)- 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.
To learn more about the concepts covered in this course, check out What Does if name == “main” Do in Python?.
Now you’re ready to go write some awesome Python main() function code!

Gregory Klassen on March 10, 2020
What does it mean to … ” or with python -m (to execute a package’s main.py file)