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

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: Programs in this video: Python if __name__ == “__main__“ (text-based tutorial): Watch our videos and revise them with our Python App! Download here for Android: Download here for iOS: 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:
Back to Top