C#3.0 and lambdas

Steve Holden steve at holdenweb.com
Wed Sep 21 09:02:02 EDT 2005


Christophe wrote:
> Serhiy Storchaka a écrit :
> 
>>Roel Schroeven wrote:
[...]

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

In which case perhaps you should actually try the code. Then once you 
realise it works you can start to figure out why :-). Hint: f(*p1) 
appears as len(p1) separate arguments to the called function.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                          www.pycon.org




More information about the Python-list mailing list