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 chris.jerdonek
Recipients bethard, chris.jerdonek, r.david.murray
Date 2013-01-07.01:47:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1357523268.03.0.846318905725.issue16878@psf.upfronthosting.co.za>
In-reply-to
Content
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=[])
History
Date User Action Args
2013-01-07 01:47:48chris.jerdoneksetrecipients: + chris.jerdonek, bethard, r.david.murray
2013-01-07 01:47:48chris.jerdoneksetmessageid: <1357523268.03.0.846318905725.issue16878@psf.upfronthosting.co.za>
2013-01-07 01:47:47chris.jerdoneklinkissue16878 messages
2013-01-07 01:47:47chris.jerdonekcreate