If __name__ == '__main__' for Python Developers

preview_player
Показать описание
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:
🔗 Discord:
🔗 LinkedIn:
🔗 Twitter:
🔗 Blog:

🎯 Sources 🎯
--------------------------------------
⭐ Python Documentation:

💳 Credits 💳
----------------------
⭐ Beautiful animated graphics by:
⭐ Beautiful icons by:

#python #pythonprogramming #python3 #pythonforbeginners #if #main #coding #programming #pythontutorial #conditioning #pythonsimplified #module #toplevel #code
Рекомендации по теме
Комментарии
Автор

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!

supermalavox
Автор

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.

anthonyoppong-gyebi
Автор

This is the best explanation of this boilerplate code I had watched so far.

JorgeEscobarMX
Автор

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!

michalbotor
Автор

I've been looking for a clear explanation of if __name__ = "__main__" for the last week and this is the only one that makes sense! TY TY TY!

txwinder
Автор

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

EmaMazzi
Автор

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 !👏🙏

trong-tintran
Автор

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! 😭😭🥺❤️🙏✨

hiutale
Автор

this is by far the most professional guide I've seen on this topic. this girl is serious

xr
Автор

The most gorgeous python teacher with most synthesized way of teaching, keep it up

xklojx
Автор

Over 10+ of python experience and I’m a proud active fan and follower. I love your teaching style, contents, personality and simply everything about you. Thank you so much for everything ❤

alaly
Автор

I've never seen someone explained this so simply before. This video is a gem.

kayingayle
Автор

The example at the very end with "from import_me import call_me" that showed it running the function just because it was imported, really helped me solidify the concept. Thank you! And thank you for all your quick videos on good python habits and explanations like this. They really do help us get through some of our projects after we've been out of the game for so long.

michaeltheisen
Автор

Well, I think I should leave a honest review!
If your video didn't have the "Why do we need to check if name == main" part, then I would have just move on and look for another resource.
But thankfully the best was reserved for last and after many failed attempts to understand "If __name__ == "__main__"" concept, I can confidently say that now I do understand it. 😊
So, thank you for understanding what newbies don't understand! 🙌 👍

ShahinHemmati
Автор

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

NoOne-L
Автор

This was actually way more insightful than I expected... Thanks, great explanation!

MrKrtek
Автор

That was very well explained. An incredible amount of work goes into eight minutes of content when you want it to be clear and concise. I really appreciate the effort. Thank you! 👍🏻👍🏻

renatomachelett
Автор

What a super wonderful and crystal clear way of explaining. :-)
Thanks lot Mariya!

RunePedersen
Автор

I just clicked this video bc I started learning Python yesterday, I have never seen a if __name__ = "__main__" in my life, yet you managed to make me understand how this works and why is it this way.

ad.chacon
Автор

Holy moly! Two days ago I was figuring out what this idiom was for and now you post about it, it's amazing.

Neotenyx