C#3.0 and lambdas

Christophe chris.cavalaria at free.fr
Mon Sep 19 10:20:50 EDT 2005


Max M a écrit :
> Steven D'Aprano wrote:
> 
>> On Mon, 19 Sep 2005 10:31:48 +0200, Fredrik Lundh wrote:
>>
>> How many items should you pass in the tuple? If it takes variable
>> arguments, then that works, but if you always expect a fixed number, then
>>
>> def func((x, y))
>>
>> is more explicit.
>>
>> The only problem I have is that once you unroll the tuple like that, 
>> it is
>> hardly necessary to pass the argument as a tuple. Why not just pass x and
>> y as two arguments?
>>
>> def func(x, y)
> 
> 
> 
> why not just pass the tuple as arguments then?
> 
> def func(*(x, y))
> 
> or as it would normally look:
> 
> def func(*arg)
> 
> That should work just as well for those cases.

I don't want to unroll x, y in the function API because the function 
signature is that it takes a position object. The fact that the position 
object just happens to be a 2 element tuples as no incidence on that. I 
want the function API to be that. Why would you ask ? Because it make 
sense to do it like that when I create a second function which takes 2 
posiiton objets.

Why should I call the first with that sytnax : f(*pos) and the second 
with that one : g(pos1, pos2)



More information about the Python-list mailing list