Hi
I saw here http://inventwithpython.com/pygame/chapter3.html
a program where the main program is put in a function.
So the structure is:
def main():
main code here
def f1():
function 1 code
def f2():
function 2 code
..
if __name__ == '__main__':
main()
The author says
On Mon, 14 Sep 2015 09:13:47 +0200, ast wrote:
> is it advised to always write programs like that ?
If global (module-scope) variables are initialised by main, then those
variables won't exist unless main() is run, which means that you can't use
it as a module, only as a script.
IMHO, global
"ast" writes:
> 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