argparse subparser problem
John O'Hagan
research at johnohagan.com
Tue Nov 16 19:33:19 EST 2010
On Tue, 16 Nov 2010, Neal Becker wrote:
> I want to have subparsers, but I also want to be able to say:
>
> myprogram --version
> and get the version #
>
> ---------------------------
[...]
AFAIK, it is not possible ATM to have optional subparsers with argparse:
http://code.google.com/p/argparse/issues/detail?id=47
To do something like what you want, I've done my own pre-parsing of the
command-line to separate out sub-options, and then sent them to multiple
separate top-level ArgumentParser instances.
Regards,
john
More information about the Python-list
mailing list