[Chicago] order of keyword arguments

Carl Karsten carl at personnelware.com
Thu Feb 5 06:39:17 CET 2009


Igor Sylvester wrote:
> Is this worthy of a PEP?
> 
> On Wed, Feb 4, 2009 at 9:05 PM, Ian Bicking <ianb at colorstudy.com> wrote:
> 
>> On Wed, Feb 4, 2009 at 12:07 PM, Igor Sylvester <igorsyl at gmail.com> wrote:
>>
>>> Hi Everyone,
>>>
>>> Is there a way to obtain the order of keyword arguments in this example:
>>>
>>> def foo(**kargs):
>>>             print kargs.items()
>>>
>>> The call foo(A=0, B=1) could print (('A', 0), ('B', 1)) or (('B', 1),
>>> ('A', 0)).

What is the use case for this?

>>>
>>> Since dictionaries do not know about ordering, I can't obtain the order of
>>> keyword arguments by simply looking into kargs.
>>> Perhaps there is a way to introspect the function stack to get a hold of
>>> the order of the arguments.  Does anyone know if this is possible?

Carl K

>>>
>> Nah, it's not really possible.  You could look back in the function stack,
>> find the line number, parse the line, try to resolve symbols to determine
>> which part of the code refers to your function... but really, no, no way to
>> do it.
>>




More information about the Chicago mailing list