Chris Jerdonek added the comment:

I was referring to the fact that optionals have an additional case that 
positionals don't have: "Note that for optional arguments, there is an 
additional case -- the option string is present but not followed by a 
command-line argument."

(from http://docs.python.org/dev/library/argparse.html#nargs )

>>> p.add_argument('--foo', nargs='*', default=None)
>>> p.parse_args([])
Namespace(foo=None)
>>> p.parse_args(['--foo'])
Namespace(foo=[])

So it could be argued that positionals (at least by default) are behaving like 
the second case.  But that's as far as the parallel goes apparently.  *default* 
affects the first case and not the second case for optional arguments:

>>> p.add_argument('--foo', nargs='*', default=False)
>>> p.parse_args([])
Namespace(foo=False)
>>> p.parse_args(['--foo'])
Namespace(foo=[])

----------

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

Reply via email to