Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #96553
| Path | csiph.com!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Nobody <nobody@nowhere.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Putting the main program in a main function |
| Date | Mon, 14 Sep 2015 08:25:05 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 16 |
| Message-ID | <pan.2015.09.14.07.25.04.87000@nowhere.invalid> (permalink) |
| References | <55f673b3$0$3342$426a74cc@news.free.fr> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="152d4dee6f95183c956ee6fa63d7e69f"; logging-data="17620"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//NIN6x6b6SO26A+knuF/C" |
| User-Agent | Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.) |
| Cancel-Lock | sha1:1CJCpyz8gli+TzJvxNtFCyH+B8w= |
| Xref | csiph.com comp.lang.python:96553 |
Show key headers only | View raw
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