Well, I finally ran into a Python Unicode problem, sort of

Steven D'Aprano steve at pearwood.info
Sun Jul 3 22:33:35 EDT 2016


On Mon, 4 Jul 2016 07:28 am, Lawrence D’Oliveiro wrote:

> On Monday, July 4, 2016 at 6:39:45 AM UTC+12, John Ladasky wrote:
>> Here's another worm for the can.  Would you rather read this...
>> 
>> d = sqrt(x**2 + y**2)
>> 
>> ...or this?
>> 
>> d = √(x² + y²)
> 
> Neither. I would rather see
> 
>     d = math.hypot(x, y)
> 
> Much simpler, don’t you think?

Only if you think of x and y as the sides of a triangle, and remember
that "hypot" is a Unix-like abbreviation for hypotenuse (rather than,
say, "hypothesis". And it doesn't help you one bit when it comes to:

a = √(4x²y - 3xy² + 2xy - 1)


Personally, I'm not convinced about using the very limited number of
superscript code points to represent exponentiation. Using √ as an unary
operator looks cute, but I don't know that it adds enough to the language
to justify the addition.



-- 
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list