Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Skimming the book, it does not use type annotations in its functions. I would talk about type annotations and encourage their use soon after presenting the concept of functions. Agree?


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.


I 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.


They 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.


Type annotations are fairly new and advanced material. The vast majority of code you'll encounter in the wild doesn't use them. They can and probably should be omitted in a beginner intro.


No, types are distracting at first.


Cool idea. I'd want to see how it goes in a course.


type annotation is actually a fairly niche functionality. It is bad that most people cannot judge by themselves and just follow the hype.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: