Ask HN: Advanced Python Coding Books

32 points by excitednumber ↗ HN
What is a highly recommended advanced python (3.x+) concepts and coding book?

@decorators for class methods, type coercion, other stuff that may be deemed "interesting" or advanced that I'm not thinking of.

I came across a few books published ~2013 which I'd consider dated.

It may also just be a matter of reading the latest python documentation.

Thanks for any input.

15 comments

[ 3.5 ms ] story [ 30.4 ms ] thread
Effective Python by Brett Slatkin is very good, still going through the Second Edition, but I like the practical side of this book.

If you want to go really deeper like the inner working of CPython I'd recommend Anthony Shaw's CPython internals. It has been on my radar for some time now, still going through the serie of blog posts from tenthousandmeters[0]

0: https://tenthousandmeters.com/blog/python-behind-the-scenes-...

As an intermediate to advanced Python text book, I would highly recommend Fluent Python.

It covers a lot of the fundamental concepts in Python explaining why a lot of things are as they are.

Also, can you recommend beginner python books. thanks.
Automate the Boring Stuff with Python and Python Crash Course were both pretty great.

The first one you can read online for free legally. I'm not sure about the second one.

https://automatetheboringstuff.com

Fluent Python 2nd ed. is available as a preprint on oreilly.com. Highly recommended.
Python 201 is a great resource. I've recommended it to a lot of people. Fluent Python is also great. There is a physical version of the CPython book by Anthony Shaw.

Additionally, have you tried visiting a random page of the Python Documentation? I recommend reading about the data model [1], or the execution model [2], the import system [3], and the data types sections [4]

I also recommend reading a few of the PEPs. Some of the more recent ones which are really interesting are:

1. PEP 635 - Structural Pattern Matching: Motivation and Rationale [5] 2. PEP 636 - Structural Pattern Matching: Tutorial [6] 3. PEP 483 - The Theory of Type Hints [7] 4. PEP 572 - Assignment Expressions [8]

The thing about books is that while they're are a good introduction, you won't get these things from the books. The docs exist for a reason, and if they're not good, feel free to file a PR. However note that the Python docs are really well written :)

I also personally recommend the RealPython blog. It has a LOT of articles on the topics you mentioned. On the note of decorators btw, you should learn how to use two python functions: `id`, and `dir` [9]. They are the most powerful tools in my repertoire, and I only grok the advanced topics because I know how to use these.

References: 1. https://docs.python.org/3/reference/datamodel.html 2. https://docs.python.org/3/reference/executionmodel.html 3. https://docs.python.org/3/reference/import.html 4. https://docs.python.org/3/library/datatypes.html 5. https://www.python.org/dev/peps/pep-0635/ 6. https://www.python.org/dev/peps/pep-0636/ 7. https://www.python.org/dev/peps/pep-0483/ 8. https://www.python.org/dev/peps/pep-0572/ 9. https://realpython.com/lessons/dir-function/

My personal favorite is Expert Python Programming by Tarek Ziadé and Michał Jaworski.

Python High Performance by Gabriele Lanaro is also quite good.