logoalt Hacker News

intalentive12/10/20241 replyview on HN

After taking a programming languages course I came away with the impression that Python is untyped. Type annotations are not required or enforced, and expression types are not evaluated prior to execution. So here’s another vote for the academics.


Replies

kstrauser12/10/2024

The result of the expression is not compared to an annotation if there isn't one, but that result absolutely has a type of its own.

And the objects inside an expression assuredly care about their types:

  >>> '1' + 1
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  TypeError: can only concatenate str (not "int") to str