Roel Schroeven wrote: > ... > Christophe schreef: >> ... >>And what about a function which computes the line length ? > > That would have been a better example indeed, since the *p1 trick > doesn't work there. > > def euclidian_distance((x1, y1), (x2, y2)): > return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) > > That's a lot nicer, I think, than this: > > def euclidian_distance(p1, p2): > return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2) But not massively nicer than: def euclidian_distance(p1, p2): (x1, y1), (x2, y2) = p1, p2 return math.sqrt((x2 - x1)**2 + (y2 - y1)**2) --Scott David Daniels Scott.Daniels at Acm.Org
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4