filmov
tv
Python Tutorial for Beginners 40 - Idea behind : if __name__ == '__main__'

Показать описание
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 ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
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!
#PythonTutorialforBeginners #ProgrammingKnowledge #LearnPython #PythonCourse
★★★Top Online Courses From ProgrammingKnowledge ★★★
★★★ Online Courses to learn ★★★
★★★ Follow ★★★
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!
Комментарии