Putting the main program in a main function
nomail at invalid.com
Mon Sep 14 09:13:47 CEST 2015
I saw here http://inventwithpython.com/pygame/chapter3.html
a program where the main program is put in a function.
So the structure is:
main code here
function 1 code
function 2 code
if __name__ == '__main__':
The author says that with this structure there are no
global variables (except when using "global' keyword)
and that the program can be loaded as a module without
be ran to test the function in the python shell.
is it advised to always write programs like that ?
More information about the Python-list