This a preview of a video course about the __name__ == "__main__" idiom works in Python. You’ve likely encountered Python’s if __name__ == "__main__" idiom when reading other people’s code. You might have even used this idiom in your own scripts. But did you use it correctly?
This line of code can seem a little cryptic, so don’t fret if you’re not completely sure what it does.
This is a portion of the complete course, which you can find here:
https://realpython.com/courses/if-name-main-python/
The rest of the course covers:
- When you should use this technique
- How you should structure the code
- When you shouldn't use it