If __name__ == ‘__main__’ Flashcards
1
Q
Why would you use “if __name__ = ‘__main__’
A
- Module can be run as a stand alone program
- Module can be imported and used by other modules
2
Q
How does “__name__” work
A
Python sets ‘special variables’, one of which is __name__ then Python will execute the code found within “__main__”
3
Q
What does it mean if the __name__ of the module is __main__
A
That means that the module being used is the one being run directly