Author nstiurca
Recipients nstiurca
Date 2012-06-21.15:34:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1340292847.64.0.123942573403.issue15125@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-06-21 15:34:07nstiurcasetrecipients: + nstiurca
2012-06-21 15:34:07nstiurcasetmessageid: <1340292847.64.0.123942573403.issue15125@psf.upfronthosting.co.za>
2012-06-21 15:34:06nstiurcalinkissue15125 messages
2012-06-21 15:34:05nstiurcacreate