If __name__ == "__main__" for Python Developers
If name equals main β then we run our programs!
But do we actually understand what is __name__ , what is __main__ and most of all β why do we need to check if they match? π€π€π€
Iβve prepared this very special tutorial that dives deep into each component and demonstrates it thorough simple code examples. By the end of this video β youβll be able to explain this expression in your own words (!!!) as well as other terms like βmoduleβ and even βtop level codeβ π
β° TIME STAMPS β°
ββββββββββββββ
00:00 β Intro
00:29 β What is __name__
00:59 β What is module?
01:34 β Top level code vs imported code
03:35 β What is __main__
05:08 β Find the value of __name__
05:55 β Why do we need to check if name == main
08:08 β Thanks for watching!
π€ Connect with me π€
βββββββββββββ
π Github:
https://github.com/mariyasha
π Discord:
https://discord.com/invite/wgTTmsWmXA
π LinkedIn:
https://ca.linkedin.com/in/mariyasha888
π Twitter:
https://twitter.com/mariyasha888
π Blog:
https://www.pythonsimplified.org
π― Sources π―
βββββββββββββ
β Python Documentation:
https://docs.python.org/3/library/__main__.html
π³ Credits π³
βββββββ-
β Beautiful animated graphics by:
mixkit.co
β Beautiful icons by:
flaticon.com