Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53385 > unrolled thread

Re: argparse - specify order of argument parsing?

Started byCameron Simpson <cs@zip.com.au>
First post2013-09-01 09:44 +1000
Last post2013-09-01 09:44 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: argparse - specify order of argument parsing? Cameron Simpson <cs@zip.com.au> - 2013-09-01 09:44 +1000

#53385 — Re: argparse - specify order of argument parsing?

FromCameron Simpson <cs@zip.com.au>
Date2013-09-01 09:44 +1000
SubjectRe: argparse - specify order of argument parsing?
Message-ID<mailman.430.1377994347.19984.python-list@python.org>
On 31Aug2013 14:17, Terry Reedy <tjreedy@udel.edu> wrote:
| On 8/31/2013 2:13 PM, Terry Reedy wrote:
| >On 8/31/2013 1:11 PM, Eduardo Alvarez wrote:
| >>When using argparse, is there a way to specify in what order arguments
| >>get parsed?
| >
| >I expect argparse to forward iterate the sequence of arguments that it
| >receives.
| 
| Aside from the environment variable solution, you could search
| sys.argv for 'config=filename' and remove it and process it *before*
| you invoke argparse.

Although, speaking for myself, I like options to have effect as encountered:

  some-cmd -a --no-foo

Would turn on "all" options then turn off "foo". Hard to do if you look for
"more important" options and then less important options.

I'm personally against out-of-order option handling; it confuses things for the user.
If you (as the user) need the config file to be known first, put it first.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

You wouldn't... ...but you KNOW you could.      - Original V65 Commercial

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web