Are there any good books that deal with writing pythonic code? As well as being focused on more intermediate or advanced features like this? If the book is project focused that's a bonus. Performance trade-offs another bonus.
I can personally recommend Fluent Python (its 2nd edition is about to come out in a couple months) for learning these intermediate/advanced concepts, and Python Cookbook for code examples using many of these features.
I don't know any books for projects per-se, maybe HN will know!
To me it looks like a lot of this knowledge is spread out over many different excellent technical blogs like yours. While the content is good, it's hard to get something that resembles a more complete picture compared to just another piece of a big puzzle.
Fluent Python is definitely a good book, I knew a whole bunch of the stuff in this article because of it. I only got to Chapter 9, but it legitimately made my Python much, much better.
The solutions presented typically include both a "basic" approach, a "as pythonic as possible" approach, and a brief discussion of the trade-offs between elegance and readability, etc.
I would recommend "Robust Python" by Patrick Viafore. It teaches you a lot about type annotations (among other thing) and gave me personally a whole new way of looking at the code that I write.
Author of Robust Python here: I definitely recommend Fluent Python as well once the 2nd edition is available. I wrote Robust Python to focus very much on how to write Python in a long-lived codebase and how to do trade-offs for readability/maintainability/testability/etc. It also covers a lot of things outside of standard built-ins (such as acceptance testing, mutation testing, pydantic, type checkers, etc.). I find Fluent Python to be more focused on more of the built-ins, and I think it might cover some of the performance trade-offs you might be looking for.
Long story short : I think both have a lot of value (but beware I'm quite biased on Robust Python)
In a way, learning Python is harder for people experienced with another language because so much of the content you find is for first-time programmers.
That said, I think I had good luck with Writing Idiomatic Python.
When I learned Kotlin, I just read through the docs, and then knew of basically all the different concepts in the language.
For Python, the docs were comparably very bad. For instance, Decorators aren't mentioned even once in the "The Python Tutorial". In "The Python Language Reference" (if one even bother to read such a dry document) it's barely mentioned in passing. How should a new user know it's a concept and how to apply it? And the language reference links only to a glossary item, and none of them specify how parameters in a decorator is supposed to work.
Pretty frustrating experience, put me a bit off the language from the get-go.
If you read the docs then you basically would not know about them. My experience mirrors the people upthread. I also found that the Python community is very hostile to the idea that the docs might be insufficient, in that people suggesting this in threads were frequently belittled or it was often suggested that the questant should just learn it like they did, or that it wasn't really all that hard.