4 ms·
No. Type annotations are pointless because they are not enforced in any way – if you're coming from another language it might be really misleading. It's good
by runxel 7y ago
No. Type annotations are pointless because they are not enforced in any way – if you're coming from another language it might be really misleading.
It's good the author omitted this information. Also most code in the wild doesn't use it anyway.
- DonaldPShimoda 7y agoI think in general you're right, but I think it's wrong to say type annotations are "useless" without some qualification of that statement. I use PyCharm as my Python IDE, which does some static analysis on type annotations to ensure consistency and to give better autocompletion hints, which I find very useful.
- Bostonian 7y agoThey are not pointless if you run code through mypy, an optional static type checker for Python. Most Python code does not use annotations, but that's because annotations are a relatively new feature and because Python programmers are not used to using annotations. Maybe beginners should get in the habit of using annotations when a function only makes sense specific argument types.