[issue11076] Iterable argparse Namespace

Virgil Dupras report at bugs.python.org
Mon Jan 31 09:05:03 CET 2011


New submission from Virgil Dupras <hsoft at hardcoded.net>:

Currently, there is no (documented) way to easily extract arguments in an argparse Namespace as a dictionary. This way, it would me easy to interface a function taking a lot of kwargs like this:

>>> args = parser.parse_args()
>>> my_function(**dict(args))

There's "_get_kwargs()" but it's a private undocumented method. I guess that making it public would be problematic because of the namespace pollution that would occur. That's why I'm proposing to make it iterable.

If it isn't rejected, I'd gladly work on the required patch.

----------
components: Library (Lib)
keywords: easy
messages: 127582
nosy: vdupras
priority: normal
severity: normal
status: open
title: Iterable argparse Namespace
type: feature request
versions: Python 3.3

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


More information about the Python-bugs-list mailing list