Message163340
To reproduce, try the following code:
from argparse import ArgumentParser
a = ArgumentParser()
a.add_argument("foo-bar")
args = a.parse_args(["biz"])
print args, args.foo_bar
Expected output:
Namespace(foo_bar='biz') biz
Actual output:
Namespace(foo-bar='biz')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Namespace' object has no attribute 'foo_bar'
Other comments:
The positional argument 'foo-bar' becomes impossible to retrieve without explicitly passing keyword argument dest='foo_bar'. Hyphens in positional arguments should be automatically replaced with underscores just as with other arguments.
I have not tested if this problem occurs in Python versions newer than 2.6. |
|
Date |
User |
Action |
Args |
2012-06-21 15:34:07 | nstiurca | set | recipients:
+ nstiurca |
2012-06-21 15:34:07 | nstiurca | set | messageid: <1340292847.64.0.123942573403.issue15125@psf.upfronthosting.co.za> |
2012-06-21 15:34:06 | nstiurca | link | issue15125 messages |
2012-06-21 15:34:05 | nstiurca | create | |
|