Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 4: Journal app and file I/O
Lecture: Core concept: __name__ and imports

Login or purchase this course to watch this video and the rest of the course contents.
0:00 That brings us to our final core concept, this __name__ variable, or sometimes referred to as __name__.
0:11 So we saw this __name__ variable is available in all modules and Python scripts, and the convention is it's set to the name of the file,
0:20 if the file is being imported, otherwise it's set to __main__. __main__, right? And we use this trick or this convention to determine
0:32 how our should execute. In our example we decided do we run the main method in the event loop
0:38 or do we just define the functions and actually skip running the main because we are not the program we are just being used by another program.


Talk Python's Mastodon Michael Kennedy's Mastodon