3 ms·
> Everything is a spelunking expedition, and there's no type safety or anything to help you figure it out. For any significant Python codebase, I make sure to
by crazypython 6y ago
> Everything is a spelunking expedition, and there's no type safety or anything to help you figure it out.
For any significant Python codebase, I make sure to put extra effort into precise and strict type annotations so I can rely on type safety. Sometimes after fixing all the statically detected type problems, my program works on the first try.
Python was strongly typed from the beginning, before it was statically typed. When you add a string to a number in Python, you get a type error. Python's static type system– which is formally part of the language and has multiple implementations– is an elegant and natural fit to the language. Unlike TypeScript, where the type system is artificial, and restricts what you can do with JavaScript.
Language features that made it into ruby– like blocks and unless– were rejected from Python because they would have made it possible to create advanced DSLs, which is something the language maintainers aim to avoid– enabling the creation of arcane application-specific special languages.
PEP-484 is the static type system's name: https://www.python.org/dev/peps/pep-0484/ https://www.python.org/dev/peps/pep-0484/ (implementations include mypy and Pyre)