command-line args

Peter Hansen peter at engcorp.com
Sat Apr 24 10:54:07 EDT 2004


Michael [mailto:mogmios at mlug.missouri.edu] wrote:
> Peter Hansen wrote:
> > Create an empty module called "globals" and import that wherever 
> > needed.  Populate it with settings from the command-line parsing 
> > stage.  Get fancier and put defaults in there to begin with, and 
> > override them only if specified in the command-line parsing area.  
> > Flavour as needed...
> 
> What do you do about multiple processes (of the same program) 
> running at once? Save to /tmp/<pid>/globals.py or something like that?

Why would you save anything?  If you're just parsing command-line
arguments, the settings are not persistent, are they?  Just
kept in memory for the duration of the current program.  If you
have multiple processes, each gets its own command line arguments
and thus its own in-memory values from globals.py. 

If you are actually interested in persistent, you'll need to 
expand on your original question, I think, because talking 
about "command line argument parsing" generally doesn't 
involve persistence, for most people.

-Peter





More information about the Python-list mailing list