Without the main sentinel, the code would be executed even if the script were imported as a module.
More Related Contents:
- Best way to return multiple values from a function? [closed]
- Single quotes vs. double quotes in Python [closed]
- Dictionaries and default values
- What are the most common Python docstring formats? [closed]
- Styling multi-line conditions in ‘if’ statements? [closed]
- Forced naming of parameters in Python
- Python import coding style
- Python `if x is not None` or `if not x is None`? [closed]
- Python exception chaining [duplicate]
- How to break a line of chained methods in Python?
- In Python, is it better to use list comprehensions or for-each loops?
- Should I use `import os.path` or `import os`?
- python close file descriptor question
- Python import mechanics
- Alternatives for returning multiple values from a Python function [closed]
- Is nested function a good approach when required by only one function? [closed]
- Creating an empty list in Python
- In Python, when should I use a function instead of a method?
- Importing modules in Python – best practice
- Is making in-place operations return the object a bad idea?
- identity versus equality for None in Python
- Tool to convert Python code to be PEP8 compliant
- Python coding standards/best practices [closed]
- Line continuation for list comprehensions or generator expressions in python
- Attributes initialization/declaration in Python class: where to place them?
- How can we force naming of parameters when calling a function?
- Length of longest word in a list
- Why does PEP-8 specify a maximum line length of 79 characters? [closed]
- Pandas read csv file with float values results in weird rounding and decimal digits
- How to set opacity of background colour of graph with Matplotlib