Message179239
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=[]) |
|
Date |
User |
Action |
Args |
2013-01-07 01:47:48 | chris.jerdonek | set | recipients:
+ chris.jerdonek, bethard, r.david.murray |
2013-01-07 01:47:48 | chris.jerdonek | set | messageid: <1357523268.03.0.846318905725.issue16878@psf.upfronthosting.co.za> |
2013-01-07 01:47:47 | chris.jerdonek | link | issue16878 messages |
2013-01-07 01:47:47 | chris.jerdonek | create | |
|