FAQ

Pascal Chambon wrote:


I've encountered several times, when dealing with adaptation of function
signatures, the need for explicitly resolving complex argument sets into
a simple variable mapping. Explanations.


Consider that function:

def foo(a1, a2, *args, **kwargs):
pass

calling foo(1, a2=2, a3=3)

will map these arguments to local variables like these:
{
'a1': 1,
'a2': 2,
'args': tuple(),
'kwarg's: {'a3': 3}
}

That's a quite complex resolution mechanism, which must handle
positional and keyword arguments, and deal with both collision and
missing argument cases.
Is that routine exposed to python, somewhere ? Does anybody know a
working implementation here or there ?
http://docs.python.org/library/inspect.html#inspect.getcallargs

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
grouppython-list @
categoriespython
postedDec 12, '10 at 9:15p
activeDec 13, '10 at 6:53p
posts3
users2
websitepython.org

2 users in discussion

Pascal Chambon: 2 posts Peter Otten: 1 post

People

Translate

site design / logo © 2022 Grokbase