by dec0dedab0de · 6y ago · 0 comments
Small nitpick about the title: Python is strongly typed.
Sorry about the confusion. Mys is statically typed. I changed the HN post from strongly to statically to make it clear.
Python determines the types at runtime, but it is very clear about what few operations you're allowed to do on any given set of types.
def foo():
return 1 + "2"
Another example showing Python is untyped: x = 1
x = "2"
x clearly has no type. No variables in python have types.Your first example demonstrates that python does not have compile time type checking
Your second example demonstrates that python variables can dynamically change types.
>>> 1 + "2"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
https://dev.to/jiangh/type-systems-dynamic-versus-static-str...