|
|
|
|
|
by lelanthran
636 days ago
|
|
> You'll get a runtime TypeError if you try to add a number to a string, for example, A popular but nonsensical myth: $ cat t.py
def foo(myval):
return myval * 12
print (foo("a"))
$ python3 t.py
aaaaaaaaaaaa
In real-world usage, Python's "typing" is about as helpful as Javascript's "typing". Plain old C has stronger typing guarantees than Python/PHP/etc. |
|
You have a point that strong vs weak typing is not a binary and that different languages can enable a varying amount of implicit conversions in whatever context (not to mention reinterpretation of the underlying memory). But from ~20 years of experience, Python's type system is nothing like JavaScript's - and it's definitely helpful to those who understand it and don't fight against it.
In my experience it's typically people from languages like Haskell that can't see the difference.