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
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
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
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
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
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.
>
>