If __name__ == "__main__" for Python Developers
383,469
Published 2022-11-27
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:
github.com/mariyasha
π Discord:
discord.com/invite/wgTTmsWmXA
π LinkedIn:
ca.linkedin.com/in/mariyasha888
π Twitter:
twitter.com/mariyasha888
π Blog:
www.pythonsimplified.org/
π― Sources π―
--------------------------------------
β Python Documentation:
docs.python.org/3/library/__main__.html
π³ Credits π³
----------------------
β Beautiful animated graphics by:
mixkit.co
β Beautiful icons by:
flaticon.com
#python #pythonprogramming #python3 #pythonforbeginners #if #main #coding #programming #pythontutorial #conditioning #pythonsimplified #module #toplevel #code
All Comments (21)
-
I like it when youtubers describe their code(s) verbally as they go along. For a blind person such as myself, it is of great help, since screen readers normally don't speak the contents inside videos, only in their descriptions, so if you say what you are doing while you write/show the code, the explanation becomes accessible! Thanks and keep up the good work!
-
Did you guys watch the video at all before commenting? Please watch it. That's how you will learn. She is here to educate, not for fans.
-
you've achieved mastery in clean, logical, and engaging explanations of programming concepts. my understanding of the topic has increased substantially. thanks so much mariya!
-
This was actually way more insightful than I expected... Thanks, great explanation!
-
I have been wondering this for ages, thank you for breaking it down so simply. You are the best!!
-
So thorough with great examples/visuals! Great job π. I look forward to more.
-
Your lessons Mariya really worth every seconds spentβ¦watched dozens of videos regarding this topic (if _name_ == β__main__ββ¦) and for the very first time I understand what it does actually π thank you, thank you, thank you
-
Wow! Your channel was recommended to me a few months back and I kept passing it. Glad I finally watched 1 of your video. Youβre such a great teacher. You make complex stuff simple. Thanks and will watch more videos from you
-
I am a French developer, beginner in python, and your tutorial is extremely clear, I understood everything! I often avoid English tutorials because the YouTuber speaks quickly and I have trouble following but here I have nothing to complain about, your English is simple and easy to understand. I subscribe to your channel +1. Thank you very much for this wonderful work. This is the first time I've posted a message on Youtube in my entire life π but it's well deserved !ππ
-
As always, the best and cleary explanation from entire Youtube platform. Thank you so much!!!
-
I'm purely amazed by your explanations! I only had to backtrack (a bit) once to understand all of it even though I'm still a beginner. You are the hero function we needed to call! πππ₯Ίβ€οΈπβ¨
-
Excellent explanation! You have included some essential features of this statement that makes it all so much more understandable, unlike many other explanations I have seen on YouTube. Thanks!
-
This was such a good video! I've always been curious about this, but never really looked it up. Now it makes sense :) Thanks for the clear explanation!
-
Amazing content! Pleeease keep it up! You built it up like a crescendo and suddenly became crystal clear why this "if __name == __main__:" stuff is so necessary.
-
I used to scroll down and pass your videos but now i am hooked as your methods of teaching is really easy. Thanks again
-
Iβm really enjoying your videos a lot. Iβve been wondering why I write that exact line of code for weeks, with no clue as to why. Once again, you nailed it! Your way of explaining things in a digestible manner for a total beginner is unparalleled. Thank you for sharing.
-
Great video. Thorough yet succinctly presented. Awesome job ππ»
-
So much quality in this video. Simply perfection. Even thought I know a lot about if _name_ == '__main__' I found an additional information I've never know.
-
What a super wonderful and crystal clear way of explaining. :-) Thanks lot Mariya!
-
If only everyone could explain things as clearly as you do. Nice job, thank you.