#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


Watch video #8: Python if __name__ == '__main__' | Python Best Practices online without registration, duration hours minute second in high quality. This video was added by user Programiz 21 April 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 11,965 once and liked it 285 people.