Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96553
| From | Nobody <nobody@nowhere.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Putting the main program in a main function |
| Date | 2015-09-14 08:25 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <pan.2015.09.14.07.25.04.87000@nowhere.invalid> (permalink) |
| References | <55f673b3$0$3342$426a74cc@news.free.fr> |
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 top level. 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.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Putting the main program in a main function "ast" <nomail@invalid.com> - 2015-09-14 09:13 +0200 Re: Putting the main program in a main function Nobody <nobody@nowhere.invalid> - 2015-09-14 08:25 +0100 Re: Putting the main program in a main function Ben Finney <ben+python@benfinney.id.au> - 2015-09-14 17:32 +1000
csiph-web