Putting the main program in a main function
nobody at nowhere.invalid
Mon Sep 14 09:25:05 CEST 2015
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 variables whose initial values can be evaluated without
depending upon or modifying external state should be initialised at the
If a module has variables which cannot be so initialised, the module needs
to provide an initialisation function which must be called explicitly by
any program or module which imports it.
More information about the Python-list