Directly calling python's function arguments dispatcher

Pascal Chambon chambon.pascal at wanadoo.fr
Mon Dec 13 13:53:31 EST 2010


Le 12/12/2010 23:41, Peter Otten a écrit :
> 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
>
>    
Too sweeeeeeeeeet  \o/

Thanks a lot,
regards,
Pakal



More information about the Python-list mailing list