Closed GoogleCodeExporter closed 9 years ago
I'm not sure how to fix this in general -- "type" doesn't have to actually be a
type.
For example, the following is okay:
>>> parser = argparse.ArgumentParser()
>>> action = parser.add_argument('--foo', type=lambda x: int(x) + 1, default=2)
>>> parser.parse_args(['--foo', '3'])
Namespace(foo=4)
>>> parser.parse_args([])
Namespace(foo=2)
But I can't do an isinstance check on the action's type::
>>> isinstance(2, action.type)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
I'm open to patches though if you see a way to get your error caught without
provoking the above error.
Original comment by steven.b...@gmail.com
on 1 Mar 2010 at 7:22
Closing as WontFix. If you have a specific alternative behavior you'd like
implemented, please file a new issue at bugs.python.org.
Original comment by steven.b...@gmail.com
on 23 Jul 2010 at 12:51
Original issue reported on code.google.com by
sstein...@gmail.com
on 14 Feb 2010 at 2:49