Author steven.daprano
Recipients mark.dickinson, rhettinger, skrah, steven.daprano, tim.peters
Date 2018-03-17.00:36:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1521246998.03.0.467229070634.issue33089@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-03-17 00:36:38steven.dapranosetrecipients: + steven.daprano, tim.peters, rhettinger, mark.dickinson, skrah
2018-03-17 00:36:38steven.dapranosetmessageid: <1521246998.03.0.467229070634.issue33089@psf.upfronthosting.co.za>
2018-03-17 00:36:38steven.dapranolinkissue33089 messages
2018-03-17 00:36:37steven.dapranocreate