C#3.0 and lambdas

Serhiy Storchaka storchaka at ksf.kiev.ua
Wed Sep 21 07:41:49 EDT 2005


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)

-- 
Serhiy Storchaka



More information about the Python-list mailing list