[Chicago] order of keyword arguments

Ian Bicking ianb at colorstudy.com
Thu Feb 5 04:05:41 CET 2009


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20090204/1b708f91/attachment.htm>


More information about the Chicago mailing list