argparse: delimiter for argparse list arguments

Roel Schroeven roel at roelschroeven.net
Tue Aug 3 18:49:08 EDT 2021


Jon Ribbens via Python-list schreef op 3/08/2021 om 22:55:
> >> Loads of git commands do this. e.g. commit, diff, log, status, etc.
> >> It's not completely unlike what you're describing above, which is
> >> already supported automatically by argparse.
> >
> > Commands like git commit do not use '--' to separate two lists, but as 
> > Dan and Sven said to separate options from arguments,
>
> That is not quite correct. Check out 'git diff' for example - it takes
> as position arguments zero, one, or two commit hashes followed by zero
> or more pathnames.  You can use '--' to separate these two lists,
> because of course sometimes a pathname can be indistinguishable from
> a commit hash.
Ah yes, I stand corrected, git diff indeed uses -- to separate two lists 
(commits and paths).

-- 
"Too often we hold fast to the cliches of our forebears. We subject all
facts to a prefabricated set of interpretations. Too often we enjoy the
comfort of opinion without the discomfort of thought."
         -- John F Kennedy



More information about the Python-list mailing list