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

> did you know __init__.py is optional nowadays?

It has an effect, and is usually worth including anyway. I used to omit it by default; now I include it by default. Also, you say "nowadays" but it's been almost 13 years now (https://peps.python.org/pep-0420/).

> since 3.13 there is a @deprecated decorator that does what you think it does

Nice find. Probably worth mentioning it comes from the `warnings` standard library.

> the time package has functions for monotonic clocks and others not just time()

There's quite a bit in there, but I question how many people need it.

Anyway, it's always surprising to me how when other people make these lists, such a large fraction is taken up by tricks with type annotations. I was skeptical of the functionality when the `typing` standard library was introduced; I've only grown more and more wary of it, even as people continue to insist to me that it's somehow necessary.



do you know any other things you can think of that people might not be aware of? small tricks or some such, perhaps unrelated to type annotations?


I wouldn't really know what to count in that category. I usually think more about a) really beginner-level issues (and trying to figure out why they trip up beginners, and how best to teach them in detail) and b) making my own code more beautiful (a zen-like practice that mostly defies being reduced to a tips-and-tricks list).




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

Search: