#8: Python if __name__ == '__main__' | Python Best Practices

Published: 21 April 2021
on channel: Programiz
11,965
285

Step by step video tutorials to learn Python for absolute beginners!

You might have encountered the statement if _name_ == "__main__" a lot while coding in Python.

In this video, you will learn about the special _name_ attribute of a Python file and how it can be used to run the file dynamically in different contexts.

~
Run Python Online: https://www.programiz.com/python-prog...
Programs in this video: https://github.com/programiz/python-b...

Python if _name_ == "__main__" (text-based tutorial): https://www.programiz.com/python-prog...

Watch our videos and revise them with our Python App!
Download here for Android: https://bit.ly/learn-python-android
Download here for iOS: https://apple.co/3iPm6Sx

Timestamps:
0:00 Intro
0:16 What is _name_ in Python?
0:30 Running a Python File as a Script
1:34 Running a Python File as a Module
2:48 Using if conditional with _name_

Find Programiz elsewhere:
Facebook:   / programiz  
Instagram:   / _programiz  
LinkedIn:   / programiz  
Website: https://www.programiz.com

#programiz #python #specialnameattribute #learnprogramming #runpythononline


On this page of the site you can watch the video online #8: Python if __name__ == '__main__' | Python Best Practices with a duration of hours minute second in good quality, which was uploaded by the user Programiz 21 April 2021, share the link with friends and acquaintances, this video has already been watched 11,965 times on youtube and it was liked by 285 viewers. Enjoy your viewing!