It so happened that I started with django, not penetrating into the basics of Python. Now just wanted something in the console to test and realized that I do not know but there is generally a main or here, as in php you have to write directly without a function code that he volunteered? Tried to create a function named main, but for some reason it is not called. Although the code fulfills without errors. And found what that is a reserved word __main__. Tried with the same name, the create function is also not called automatically... So how then?
The code works immediately. If you have written the main function should be to call separately
Ramon.Stracke answered on July 2nd 19 at 18:27
The name "main" in Python is not reserved, just the main() function is often used, by analogy with sysname programs (for this function, see what the program does and where it all starts).
And gate if __name__ == '__main__':
need to exclude some code from the import.
Each file .py is a Python module, you can import it as a module and use the contents of it (functions, classes, and other objects). But by itself, the file does something, if its run by itself. When you import the whole module first runs, but if you want only a function module and you do not need to perform that for which the whole unit is done, it will still run the whole. Therefore, in the module placed gates, which pass only when the module runs as a separate file. When import it, the gate is not passed.
In vain you started learning Django, because there is nobody to explain these basics, and this is really the very basics of Python.