Python Tutorial for Beginners 40 – Idea behind : if __name__ == "__main__"

///Python Tutorial for Beginners 40 – Idea behind : if __name__ == "__main__"

Python Tutorial for Beginners 40 – Idea behind : if __name__ == "__main__"

FavoriteLoadingAdd to favorites

In this Python Tutorial for Beginners video I am going to show you the Idea behind using : if __name__ == “__main__” in Python. __name__ is a built in variable in Python. the value of __name__ is set to “__main__” at runtime. Each module has a name, and this name can be used to access instructions in a module. This is especially useful in a given situation: As mentioned before, the main block of a module is executed when it is imported for the first time. But what do we do if we want the block to run only if the module was started as a stand-alone program, but not if it was imported from another module? We can do this by evaluating the attribute __name__ of the module.

#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
Python Programming Course ➡️ ⚫️
Java Programming Course ➡️ ⚫️
Bash Shell Scripting Course ➡️ ⚫️
Linux Command Line Tutorials ➡️ ⚫️
C Programming Course ➡️ ⚫️
C++ Programming Course ➡️ ⚫️
PHP Programming Course ➡️ ⚫️
Android Development Course ➡️ ⚫️
C# Programming Course ➡️ ⚫️
JavaFx Programming Course ➡️ ⚫️
NodeJs Programming Course ➡️ ⚫️
Jenkins Course For Developers and DevOps ➡️ ⚫️
Scala Programming Tutorial Course ➡️ ⚫️
Bootstrap Responsive Web Design Tutorial ➡️ ⚫️
MongoDB Tutorial Course ➡️ ⚫️
QT C++ GUI Tutorial For Beginners ➡️

★★★ Online Courses to learn ★★★
Get 2 FREE Months of Unlimited Classes from skillshare –
Data Science – |
Machine Learning – |
Artificial Intelligence – |
MERN Stack E-Degree Program – |
DevOps E-degree – |
Data Analytics with R – |
AWS Certification Training – |
Projects in Java – |
Machine Learning With TensorFlow – |
Angular 8 – Complete Essential Guide –
Kotlin Android Development Masterclass –
Learn iOS Programming Building Advance Projects –

★★★ Follow ★★★
My Website –

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This help support the channel and allows us to continue to make videos like this. Thank you for the support!

source

By |2020-03-10T02:14:58+00:00March 10th, 2020|Python Video Tutorials|23 Comments

23 Comments

  1. Hturt Yada March 10, 2020 at 2:15 am - Reply

    Finally, someone explained it clear!!! I watched dozens of vids but still didn't understand it.
    So basically, this code blocks whatever is below it when the module is used in the main code

  2. flamboyant person March 10, 2020 at 2:15 am - Reply

    First time ever I understood it after watching thousand videos on youtube. Thank you. God bless you.

  3. Гражданин Миша March 10, 2020 at 2:15 am - Reply

    wow…finally I got it) subscribed.

  4. Gaurav Bhat March 10, 2020 at 2:15 am - Reply

    Thanks a ton man! This explanation was really useful and is probably the best explanation of the if _name_ =__'main__' statement.

  5. Julius Vaidila March 10, 2020 at 2:15 am - Reply

    Thanks man, the best explanation on the topic so far!

  6. Utku Aslan March 10, 2020 at 2:15 am - Reply

    finally i understood it. thank you very much

  7. Дмитрий Дмитриев March 10, 2020 at 2:15 am - Reply

    Спасибо. Это самое лучшее объяснение.

  8. Akshat Bhutra March 10, 2020 at 2:15 am - Reply

    Sir, u are great. a very nice concept of _name == __main_

  9. Mister KoK March 10, 2020 at 2:15 am - Reply

    Просто суперски объяснил.

  10. Sarvesh Agarwal March 10, 2020 at 2:15 am - Reply

    Very clear explanation, even stack overflow messed the explanation. Great job!!

  11. Enes Baran March 10, 2020 at 2:15 am - Reply

    Best explanation out there! Clear and concise.
    Subbed

  12. jskeez March 10, 2020 at 2:15 am - Reply

    Thank you

  13. Matixwastaken March 10, 2020 at 2:15 am - Reply

    Mate, excellent explanation! Thanks you so much for explaining!

  14. Ali Fener March 10, 2020 at 2:15 am - Reply

    best one.

  15. shalini sahni mankatalia March 10, 2020 at 2:15 am - Reply

    You are the best sir. Even better than bucky roberts(he is funny and doesn't bores us but still u explain a bit better)

  16. Servác Janek Vaník March 10, 2020 at 2:15 am - Reply

    Best explanation I´ve found on the internet, good job!

  17. hiro1610 March 10, 2020 at 2:15 am - Reply

    Yureka!Thanks this finally help me understanding if name == main.

  18. Shawin Mendis March 10, 2020 at 2:15 am - Reply

    clear and concise explanation

  19. anchal2107 March 10, 2020 at 2:15 am - Reply

    Hello! Thanks. Your videos are good and knowledgable. I have seen 40 videos from starting and now moving ahead to complete all your videos. I am Senior Software Engineer major DotNet. And your videos also helped me learning Python. wrote a comment to encourage your great efforts. Regards Aanchal "http://www.amctechnosoft.com"

  20. Shubham March 10, 2020 at 2:15 am - Reply

    very good

  21. Boris Grigoryan March 10, 2020 at 2:15 am - Reply

    Thank you brother. you explain very good.

  22. John G March 10, 2020 at 2:15 am - Reply

    Thanks in a million.

  23. Devanand Sharma March 10, 2020 at 2:15 am - Reply

    Best Explaination

Leave A Comment

*