logoalt Hacker News

curiousgalyesterday at 6:33 PM3 repliesview on HN

I can't help but find type hints in python to be..goofy? I have a colleague who has a substantial C++ background and now working in python, the code is just littered with TypeAlias, Generic, cast, long Unions etc.. this can't be the way..


Replies

tialaramexyesterday at 7:07 PM

Typing is a relatively easy way for the human author and the machine to notice if they disagree about what's going on before problems arise. It is unfortunate that Python doesn't do a good job with types, I was reading earlier today about the mess they made of booleans - their bool type is actually just the integers again.

show 1 reply
wiseowiseyesterday at 7:21 PM

What is the way in your opinion?

IshKebabyesterday at 6:52 PM

I strongly disagree. Python has actually done a decent job of adding type annotations into the language IMO.

If you ignore the bit where they don't actually specify their semantics anyway.

> this can't be the way..

The alternative is fragile and unmaintainable code. I know which I prefer!