Why You Should Use Python if __name__ == "__main__"

Published: 08 March 2022
on channel: k0nze
23,219
972

In this video, I show you how and why you should always use if _name_ == '__main__' in python and answer the question of why there is no Python main function. Additionally, you will see how to prevent Python modules from executing using Python __main__.

⏬ Python Cheat Sheets: https://k0nze.gumroad.com
👉 Website Article for this Video: https://k0nze.dev/posts/python-name-main

💌 Support me on Patreon:   / k0nze  
☕️ Buy me Coffee: https://www.buymeacoffee.com/k0nze
🌍 Check out my Website: https://k0nze.dev
💻 Join our Discord: https://discord.k0nze.dev
👔 Follow me on LinkedIn: https://linkedin.k0nze.dev

Recording Gear
Camera - Sony A6400: https://geni.us/zRw1
Lens - Viltrox AF 23mm f1.4: https://geni.us/RVrguGd
Microphone - Rode Wireless Go: https://geni.us/RBAOIx
Keyboard - Keychron K2 v2: https://geni.us/DPK87Xn

⏰ Timestamps:
0:00 Intro
0:17 Python does not have a main function
0:45 How does the Python interpreter work?
2:13 Prevent Python import from execution
2:33 Python _name_
4:14 Summary


Watch video Why You Should Use Python if __name__ == "__main__" online without registration, duration hours minute second in high quality. This video was added by user k0nze 08 March 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 23,219 once and liked it 972 people.