Python Tutorial: if __name__ == '__main__'

preview_player
Показать описание
#python
In this tutorial, we'll look at a common conditional statement in Python:

if __name__ == '__main__':

This allows python to distinguish between a Python module being run directly and being imported from another module.
Рекомендации по теме
Комментарии
Автор

If you've found this useful in anyway, I'd really appreciate sharing it where you can so that more people can enjoy this resource! Watch out for a personal video I'm making on my own journey and how I changed career in my 30s from boring monotony to an exciting software engineering role. If ever you needed motivation or wanted my own specific advice on how to become a self-taught developer, then you make sure you don't miss it. Will be available next week!

LivePython
Автор

Fantastic, hands on approach. 0 shitty metaphors, just an explanation while showing how to check it, and how its works. Amazing

kenonerboy
Автор

BEST actual EXPLANATION with examples that I've come across yet of:
1. the EXISTENCE of key built-in PYTHON VARIABLES;
2. that the Python Interpretor ASSIGNS VALUES to these variables even BEFORE YOUR code runs;
3. what a PYTHON MODULE simply is;
4. that Python Modules often contain both classes, libraries AND EXECUTABLE code (tests); and
5. IF you've IMPORTED one or more modules but only wish to use the CLASSES and FUNCTIONS but NOT have any (test) code EXECUTE upon use, you NEED to TEST one of these built-in variables...


Nicely done.
-Mark in North Aurora IL | USA

VOGTLANDOUTDOORS
Автор

that last part with dunder name did my head in

adventurerwannabe
Автор

I finally got Thank you for taking the time to explain this in an understandable way.

killerpoint
Автор

Absolutely fantastic! Thank you very much!

Mikosha
Автор

So much better than every other explanation

russbunya
Автор

Thank you. You’ve not only explained how this line of code works but also helped me understand how it can be used. This really boosts my learning. I’ll be checking out some of your other videos.

ericmarquois
Автор

best and simplest explanation so far, I understood it right away.

DeyonSingh
Автор

You have an awesome channel here thank you

Bandalorian
Автор

Great content, I've seen this a million times but never took the time to understand it

georgecantstandya
Автор

The only bad thing about this playlist is the time spent looking for it.

MsaybOMayl
Автор

Nice video. Although you go too fast IMHO. Thanks!

MagnusAnand
Автор

Is it possible to change __name__ to __main__ just to screw with python ? :p Great tutorıal as always

alpaslaneldemir
Автор

Excellent verbal explanation.

Visuals were sloppily arranged.

Grade: B+

Thanks for the content.

chriskeo
Автор

Another wanna be you-tuber claiming that he can teach. Waste of time.

Omar-rcli
join shbcf.ru