Steven D'Aprano <[email protected]> added the comment:
Ah wait, I appear to have misunderstood Raymond's request. Sorry Raymond!
(I've been spending too much time teaching Pythagoras' theorem and my mind was
primed to go directly from Euclidean distance to hypotenuse.)
Not withstanding my misunderstanding, if hypot supported arbitrary number of
arguments, then the implementation of distance could simply defer to hypot:
def distance(p, q):
# TODO error checking that p and q have the same number of items
return hypot(*(x-y for x,y in zip(p, q)))
giving results like this:
py> distance((11, 21), (14, 17))
5.0
In either case, I agree with Raymond that this would be a useful feature.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33089>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com