is possible to get order of keyword parameters ?

rndblnch rndblnch at gmail.com
Fri Jan 25 14:47:33 EST 2008


On Jan 25, 5:27 pm, Larry Bates <larry.ba... at websafe.com> wrote:
> Keyword arguments are normally treaded as "order independent".
> Why do you think you need to find the order?  What problem do
> you wish to solve?
>
> -Larry

On Jan 25, 7:39 pm, Duncan Booth <duncan.bo... at invalid.invalid> wrote:
> The question remains, what use is there for this?

my goal is to implement a kind of named tuple.
idealy, it should behave like this:
p = Point(x=12, y=13)
print p.x, p.y
but what requires to keep track of the order is the unpacking:
x, y = p
i can't figure out how to produce an iterable that returns the values
in the right order.
relying on a "natural" order of the key names is not possible: x, and
y are alphabetically sorted but the following example should also
work:
size = Point(width=23, height=45)
w, h = size

if you have any suggestion to implement such a thing...
thank you

renaud



More information about the Python-list mailing list