C#3.0 and lambdas
Christophe
chris.cavalaria at free.fr
Wed Sep 21 08:51:20 EDT 2005
Serhiy Storchaka a écrit :
> Roel Schroeven wrote:
>
>> Fredrik Lundh schreef:
>>
>>> meanwhile, over in python-dev land:
>>>
>>> "Is anyone truly attached to nested tuple function parameters; 'def
>>> fxn((a,b)): print a,b'? /.../
>>>
>>> Would anyone really throw a huge fit if they went away? I am willing
>>> to write a PEP for their removal in 2.6 with a deprecation in 2.5 if
>>> people are up for it."
>>
>>
>> I for one would not like to see that disappear. I like being able to
>> write, for example:
>>
>> def drawline((x1, y1), (x2, y2)):
>> # draw a line from x1, y1 to x2, y2
>> foo(x1, y1)
>> bar(x2, y2)
>>
>> instead of
>>
>> def drawline(p1, p2):
>> x1, y1 = p1
>> x2, y2 = p2
>> # draw a line from x1, y1 to x2, y2
>> foo(x1, y1)
>> bar(x2, y2)
>>
>> or
>>
>> def drawline(p1, p2):
>> # draw a line from p1[0], p1[1] to p2[0], p2[1]
>> foo(p1[0], p1[1])
>> bar(p2[0], p2[1])
>
>
> def drawline(p1, p2):
> # draw a line from p1 to p2
> foo(*p1)
> bar(*p2)
>
That one is stupid. I don't see how you can make it work without some
global storing the p1 information in foo which I would consider as very
ugly code.
More information about the Python-list
mailing list