[docs] [issue14149] argparse: Document how to use argument names that are not Python identifiers

Joseph Birr-Pixton report at bugs.python.org
Wed Feb 29 12:19:10 CET 2012


Joseph Birr-Pixton <jpixton at gmail.com> added the comment:

> I don’t understand, can you rephrase?

Sorry, I mean making Namespace subscriptable.  eg:

>>> v = argparse.Namespace(abc = 123)
>>> v
Namespace(abc=123)
>>> v.abc
123
>>> v['abc']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'Namespace' object is not subscriptable

> add_argument('foo_bar', metavar='foo-bar', ...)

This works. Thanks!

Cheers,
Joe

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14149>
_______________________________________


More information about the docs mailing list