[Chicago] order of keyword arguments
Igor Sylvester
ias at alum.mit.edu
Thu Feb 5 06:33:16 CET 2009
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)).
>>
>> 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?
>>
>
> 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.
>
>
> --
> Ian Bicking | http://blog.ianbicking.org
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090204/3c98ae7f/attachment-0001.htm>
More information about the Chicago
mailing list