3 ms·
The bugs are way more subtle than that. You're lucky if your bad programming is caught somewhere at runtime. In most cases, Python and other weakly-typed langua
by Artemis2 10y ago
The bugs are way more subtle than that. You're lucky if your bad programming is caught somewhere at runtime. In most cases, Python and other weakly-typed languages will do everything they can to fit the data you're providing with what the code is expecting. This means converting strings to numbers and the other way around, plus a lot of other oddities you would not always expect (see PHP's intval for a crash course in bad language design). All that results in bugs that are far from obvious, and that don't always raise neat exceptions.
EDIT: I stand corrected, I don't know enough about Python in particular. The argument is still valid for other languages with weak types.
- sametmax 10y agoYou clearly haven't done much Python. It doesn't do implicit convertion. Byte are separated from strings and you need to decode explicitly. You can't add '1' and 1. Python is dynamically type. It is NOT weakly typed.
- to3m 10y agoThis is actually something Python doesn't do... generally, if you have a type error in Python, you get an exception at runtime. I certainly don't disagree with what I guess will be the overall direction of your argument.
- zephyrfalcon 10y agoPython is not "weakly typed", nor does it ever automatically convert strings to numbers or the other way around.
- brianwawok 10y agoHeck with Python3 it won't even convert bytes to String.
- a3n 10y ago> In most cases, Python and other weakly-typed languages will do everything they can to fit the data you're providing with what the code is expecting. This means converting strings to numbers ... Python is strongly typed, as well as dynamically typed. In [11]: 1 + '1' --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-11-861a99da769e> in <module>() ----> 1 1 + '1' TypeError: unsupported operand type(s) for +: 'int' and 'str'