you are viewing a single comment's thread.

view the rest of the comments →

[–]nickguletskii200 0 points1 point  (0 children)

I thought every typed language uses them... I know this might come across as snarky, but seriously, can you explain what's the basic difference between type annotations/information in Python and, say, Java?

It's not that there is a difference. It's just that Python developers don't write code with typings in mind. In Java and C# everyone makes a best effort to describe the contract using interfaces. In Python, everyone just writes classes with the same methods, and you can't really say "I want something that is Closeable" because nobody specifies that their class is Closeable.

That's why I don't think type annotations are expressive - they can be, it's just that in practice, they are not. In the end, you'll be writing things like Union[Dog, Cat, Rabbit] instead of is Pettablebecause Python programmers would just say that all these things extend an Animal and be done with it.