This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author paul.j3
Recipients paul.j3, tellendil
Date 2015-05-11.17:06:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I wouldn't describe this as bug, just a nuance on how parsers and subparsers play together.

To the main parser, the subparser argument looks like another positional.   It allocates strings to it and any following positionals based on their respective 'nargs'.

The nargs for a subparser is 'A...' (argparse.PARSER), which is similar to '+' (it takes one or more strings)



    Namespace(arg1=['create', 'test'], arg2=['test2'])

Notice how 2 of the strings are allocated to arg1, and only 1 to arg2. arg2 is happy with just 1, so arg1 gets the rest.

In your example it's the subparser that is issuing the 'unrecognized arguments' message, because it doesn't have a positional argument that would take it.

Having more than one positional that takes are variable number of arguments is tricky.  I find it helpful to think in terms of how `re` would handle a pattern like `(A+)(A*)(A)`.
Date User Action Args
2015-05-11 17:06:32paul.j3setrecipients: + paul.j3, tellendil
2015-05-11 17:06:32paul.j3setmessageid: <>
2015-05-11 17:06:32paul.j3linkissue24166 messages
2015-05-11 17:06:31paul.j3create