ordered keywords?

2005-10-17 Thread Ron Adam
Is there a way to preserve or capture the order which keywords are given? >>> def foo(**kwds): ...print kwds ... >>> foo(one=1, two=2, three=3) {'three': 3, 'two': 2, 'one': 1} I would love to reverse the *args, and **kwds as well so I can use kwds to set defaults and initiate values an

Re: ordered keywords?

2005-10-17 Thread Diez B. Roggisch
Ron Adam wrote: > > Is there a way to preserve or capture the order which keywords are given? > > >>> def foo(**kwds): > ...print kwds > ... > >>> foo(one=1, two=2, three=3) > {'three': 3, 'two': 2, 'one': 1} > > > I would love to reverse the *args, and **kwds as well so I can use kwds

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Diez B. Roggisch wrote: > Ron Adam wrote: > >> >> Is there a way to preserve or capture the order which keywords are given? >> >> >>> def foo(**kwds): >> ...print kwds >> ... >> >>> foo(one=1, two=2, three=3) >> {'three': 3, 'two': 2, 'one': 1} >> >> >> I would love to reverse the *args, and

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Ron Adam wrote: > > def lamb(args): > for v in args: print v > > def feedlamb(): > print locals() > y = 20 > lamb( (lambda x=10: (x,y,x+y))() ) > print locals() > > feedlamb() > > {} > 10 > 20 > 30 > {'y': 20} > > > Cool, this is the exact behavior I was thinking of, but

Re: ordered keywords?

2005-10-17 Thread Kent Johnson
Ron Adam wrote: > drawshapes( triangle=3, square=4, color=red, > polygon(triangle, color), > polygon(square, color) ) > > This comes close to the same pattern used in SVG and other formats where > you have definitions before expressions. Why is this better than the obviou

Re: ordered keywords?

2005-10-17 Thread Ron Adam
Kent Johnson wrote: > Ron Adam wrote: > >> drawshapes( triangle=3, square=4, color=red, >> polygon(triangle, color), >> polygon(square, color) ) >> >> This comes close to the same pattern used in SVG and other formats >> where you have definitions before expressions. > >