[Python-ideas] Fwd: argparse - add support for environment variables
Brendan Moloney
moloney at ohsu.edu
Wed Feb 20 02:54:58 CET 2013
This is something I wanted before (as well as loading defaults from per user config files). A solution was proposed a while back, but it was never merged due to a lack of consensus on the API: http://code.google.com/p/argparse/issues/detail?id=35
Not sure if there is a more recent discussion.
________________________________________
From: Python-ideas [python-ideas-bounces+moloney=ohsu.edu at python.org] On Behalf Of Miki Tebeka [miki.tebeka at gmail.com]
Sent: Tuesday, February 19, 2013 3:51 PM
To: python-ideas at googlegroups.com
Cc: python-ideas
Subject: Re: [Python-ideas] Fwd: argparse - add support for environment variables
Why not:
parser.add_argument('--spam', default=os.environ.get('SPAM', 7))
Mainly because then you can't swap in different dictionaries to resolve SPAM (when specifying "env" to ArgumentParser).
The other reason is that it's making common code shorter, which is a win IMO.
More information about the Python-ideas
mailing list