nested subparsers with argparse

Peter Otten __peter__ at web.de
Mon Aug 23 16:21:44 CEST 2010


Chris Withers wrote:

> I'm looking to build a script that has command line options as follows:
> 
> ./myscript.py command subcommand [options]
> 
> I can do up to the command [options] bit with add_subparsers in
> argparse, but how do I then add a second level of subparsers?

It looks like subparsers behave like the toplevel parsers -- you can invoke 
add_subparsers() on them, too.



More information about the Python-list mailing list