4 ms·
python is type-safe if you use python3 and avoid the dynamic parts of the language using a linter.
by adsharma 7y ago
python is type-safe if you use python3 and avoid the dynamic parts of the language using a linter.
- Groxx 7y agoSince it does no checking of the annotations at runtime: I don't really think this is accurate. This prints `5` for instance: https://repl.it/repls/DarkorchidFailingComputationalscience https://repl.it/repls/DarkorchidFailingComputationalscience def do(s: int) -> str: return 5 print(do("123")) Python is duck-typed. Wrong types aren't detected until they fail to quack correctly.
- adsharma 7y agoIf you run mypy or pyre-check on the code above, it'll give you a type error, just like a C compiler would.
- Groxx 7y agoSure, but that's like saying "valgrind exists, so C has out-of-bounds checks". It doesn't. External tools have just found ways to add optional safety that the language lacks.