3 ms·
> declaring that structure with type annotations wouldn’t add any value over examples and/or unit tests Types can be exported, which means that consumers of yo
by phailhaus 7y ago
> declaring that structure with type annotations wouldn’t add any value over examples and/or unit tests
Types can be exported, which means that consumers of your library have an actual guarantee of what you are returning, rather than just hoping that the docs are up to date. Javascript is the ultimate duck-typed language given that everything is really just an object, and TypeScript is extremely effective at managing it. I can't see why Python would be any different.
- choppaface 7y agoright, a lot of python code either doesn't result in libraries (or even documentation), or library APIs often tend to focus on dicts or integral types. successful libraries like numpy and pandas focus on a very small set of well-defined objects and leverage duck typing for containers (and runtime casting for interop with native code). I'm not saying arguments in favor of static typing and annotations are invalid, but rather it's a mindset that can make much of python look very foreign. the norvig spellchecker is a key example of swath of python code where static types are essentially irrelevant.