argparse zero-length switch

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Oct 15 07:54:46 EDT 2011


Carl Banks wrote:

> So instead of typing this:
> 
> sp subcommand -s abc foo bar
> 
> they could type this:
> 
> sp subcommand @abc foo bar
> 
> Admittedly a small benefit.


I would call it a *cost* and not a benefit at all. Instead of using a
standard, familiar user interface for entering command options, you
introduce a second special purpose mechanism *just* for entering a section
name. -s is at least a mnemonic for "section", @ is not.

And it isn't like you gain any extra clarity or expressiveness, or even a
major saving of typing! "-s" vs "@". You don't even save a key stroke: "@"
requires two keystrokes, just as "-s" does. (Okay, perhaps you save a key
stroke if you type a space after the -s.)

-s section_name is pretty simple already. Spelling it @section_name is not
sufficiently more simple to make up for the burden of introducing
unfamiliar syntax.



-- 
Steven




More information about the Python-list mailing list