Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45409
| From | Henry Leyh <henry.leyh@ipp.mpg.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Determine actually given command line arguments |
| Date | 2013-05-16 09:29 +0200 |
| Organization | GWDG, Goettingen |
| Message-ID | <kn21te$2jis$1@gwdu112.gwdg.de> (permalink) |
| References | (1 earlier) <roy-C8F8F4.08245415052013@news.panix.com> <kn00fb$8kc$1@gwdu112.gwdg.de> <kn09ke$kkf$1@panix2.panix.com> <kn1rme$2cq2$1@gwdu112.gwdg.de> <qot7gizmp76.fsf@ruuvi.it.helsinki.fi> |
On 16.05.2013 08:08, Jussi Piitulainen wrote: > Henry Leyh writes: > >> But now I would also like to be able to _write_ such a config file >> FILE that can be read in a later run. And FILE should contain only >> those arguments that were given on the command line. >> >> Say, I tell argparse to look for arguments -s|--sopt STRING, >> -i|--iopt INT, -b|--bopt [BOOL], -C CONFFILE. Then 'prog -s bla -i >> 42 -C cfile' should produce a confparser compatible cfile which >> contains >> >> [my_options] >> sopt = blah >> iopt = 42 >> >> and not 'bopt = False' (if False was the program's default for >> bopt). > > Could you instead write those options that differ from the defaults? > You could parse an actual command line and an empty command line, and > work out the difference. > > So 'prog -i 3' would not cause 'iopt = 3' to be written if 3 is the > default for iopt, but would that be a problem? That's what the program does at the moment. However, I'm not quite happy with it. Generally, the user doesn't know what's the default and it would be confusing if 'prog -i 3' doesn't make 'iopt = 3' turn up in the file at the end. There may also be the case when the user (for whatever reason) _wants_ the default in the file. I think I will try the opposite instead: the program writes the whole set of options to the file. This would produce a complete and consistent configuration which automatically reflects the hierarchy in which the options were set. And the user can sort it out by hand if he wants. Regards, Henry
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 08:34 +0200
Re: Determine actually given command line arguments "Colin J. Williams" <cjw@ncf.ca> - 2013-05-15 08:03 -0400
Re: Determine actually given command line arguments Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-15 15:51 +0300
Re: Determine actually given command line arguments Roy Smith <roy@panix.com> - 2013-05-15 08:24 -0400
Re: Determine actually given command line arguments Dave Angel <davea@davea.name> - 2013-05-15 08:51 -0400
Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 14:52 +0200
Re: Determine actually given command line arguments Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-05-15 14:00 +0100
Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 15:50 +0200
Re: Determine actually given command line arguments Skip Montanaro <skip@pobox.com> - 2013-05-15 09:08 -0500
Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-15 16:39 +0200
Re: Determine actually given command line arguments Skip Montanaro <skip@pobox.com> - 2013-05-15 09:51 -0500
Re: Determine actually given command line arguments Wayne Werner <wayne@waynewerner.com> - 2013-05-15 09:16 -0500
Re: Determine actually given command line arguments roy@panix.com (Roy Smith) - 2013-05-15 11:29 -0400
Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-16 07:43 +0200
Re: Determine actually given command line arguments Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-05-16 09:08 +0300
Re: Determine actually given command line arguments Henry Leyh <henry.leyh@ipp.mpg.de> - 2013-05-16 09:29 +0200
csiph-web