Dennis Lee Bieber a écrit : > On Wed, 21 Sep 2005 17:08:14 +0200, Christophe <[EMAIL PROTECTED]> > declaimed the following in comp.lang.python: > > > >>No unpack trick ( that I know of ) can be used here. You only have 1 way >>to do it without the unpack in function parameters syntax : >> >>def length(p1, p2): >> x1, y1 = p1 >> x2, y2 = p2 >> return math.hypot(x1-x2,y1-y2) > > >>>>import math >>>>def length(p1, p2): > > ... return math.hypot(p1[0] - p2[0], p1[1] - p2[1]) > ... > >>>>length((1,2),(4,6)) > > 5.0 > > > Still no need for intermediate variables, you can index the tuple at > need.
Well, I prefer the explicit tuple unpack anyway. It gives better results than using tuple indexing ( and better performance too most of the time ) -- http://mail.python.org/mailman/listinfo/python-list