53GB

If __name__ == "__main__" for Python Developers



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

Exit mobile version