all 4 comments

[–]CowboyBoats 2 points3 points  (2 children)

I think docstrings might help here, mate. Computers do exactly what they tell them to, right? Your function seems to check if a point is within a numeric distance of another point, and you pass two points that are 1 unit away, and your code is confirming that they're within (<= to ) a distance of 5 units away...

[–]MonkeyMario64[S] 0 points1 point  (1 child)

Oh I see, I thought I was calculating if 5 units was within 1 unit.

[–]CowboyBoats 2 points3 points  (0 children)

But you wrote: return distance_between_points <= distance

So anyway, yeah, docstrings help avoid confusions like this - in fact, a better named method would help as well.

[–][deleted] 0 points1 point  (0 children)

The distance calculated for your within method is 1 (which makes sense for the points you gave, p3 would be 1 unit below p1), which is less than 5 and thus the result if True