Carl Banks <pavlovevide...@gmail.com> writes: > I have a use case where some users would have to enter a section name > on the command line almost every time, whereas other users (the ones > using only one section) will never have to enter the section name.
Sounds like a typical case where you want an option that takes an argument, with a default for when the option is not specified. As you probably know, ‘argparse’ already handles this fine. > I don't want to burden users with only one "section" to always enter > the section name as a required argument, but I also want to make it as > convenient as possible to enter the section name for those who need > to. Yes. The latter need only specify the section explicitly, with ‘-s foo’ or whatever. > My thought, on the thinking that practicality beats purity, was to > create a zero-length switch using a different prefix character (say, > @) to indicate the section name. So instead of typing this: > > sp subcommand -s abc foo bar What's wrong with that? That's a normal way to do it, consistent with other command-line interfaces. Why deviate from that? > they could type this: > > sp subcommand @abc foo bar > > Admittedly a small benefit. I don't see the benefit of that which would be worth teaching that unconventional command-line syntax. -- \ “Two paradoxes are better than one; they may even suggest a | `\ solution.” —Edward Teller | _o__) | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list