paul j3 added the comment:

I should note one caveat:

As a consequence of setting nargs to 0 for the first 'parse_know_args' step, 
all positional entries in the namespace get an empty list value ([]).  This is 
produced by 'ArgumentParser._get_values'.  With the builtin action classes this 
does not cause any problems.

However a custom action class might have problems with this [] value.
For example in 'test_argparse.py', TestActionUserDefined the PositionalAction 
class does check the values and throws an error with this [] value.

The positional arguments are removed from the namespace before it is passed on 
to the 2nd 'parse_known_args', so these [] in the first don't affect the final 
namespace.

I don't think anything about this should be added to main documentation, since 
it could confuse most readers.  I might add a note of warning to the code 
itself.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14191>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to