Python book recommendation quick 2023 01 05 2hr window

What Python book do you guys recommend?
(preferably available on Amazon for me)

I saw that the 2009 thread.

Not keen on the title, but referenced by Jordan seems really useful.

I picked up the SQL Cookbook 2nd edition for SQL, and it has helped me with one query since I got it a week ago. I think it is good, but have no real reference since I only have used the one book.
I should probably go to the library more often.

@pascal.fragnoud do you have a recommendation?
Did you write a book on Python yet haha?

I was leaning toward :
Python Pocket Reference: Python In Your Pocket (Pocket Reference (O'Reilly)) Fifth Edition
published 2014

Never read one, so I really couldn't say.
See if you can find something by Raymond Hettinger maybe ?

Frankly, I'd rather read about computer programming in general (patterns, algorithms, data structures etc) than about one language.

1 Like

Edited the original post, apparently there is a newer version of the same book.

1 Like

I don't know the best choice.
I went with this after about 2hrs research.
Thanks for helping me Alec and Pascal.

I am going with The Pragmatic Programmer 20th anniversary
I saw Raymond Hettinger mention it in a PyBay 2017 video
Effective Python: 59 Specific Ways to Write Better Python
The book says Raymond Hettinger contributed

Pascal, Raymond, and the previews were my main factors.

I thought the table of contents/organization were telling.

What I think was the biggest leap for me was learning about code smells, what they are, how to avoid and perhaps most importantly WHY they are code smells. This will really help keep your code clean (ie not smelly).

Know when you're doing something wrong and the right way to do it has helped me the most. There's one youtuber I like, ArjanCodes, who has a couple video on Python Code smells that are good. He also has "Code Roasts" where he goes over what looks like decent enough production python code, and then explains the code smells in that and how to improve it. Learning what is bad about code and how to improve, and WHY it is an improvement, I feel is probably one of the biggest things you can do for yourself. He does all his work in python 3 but many of the things are applicable to 2.5/2.7.


Thanks, I'll checkout ArjanCodes videos.

Your text reads like you discovered ArjanCodes on youtube after you had developed a sense for "code smells".
Where did you learn about that?

I like this dude: his videos are about advanced topics and concepts, that actually are useful and that you don't just find easily when typing "how do I do X in python" on google.


For _ in range(9):

Arjan used this notation in one of his videos for an example.

I usually say:

For i in range(9):

Is this just a preference or is there some value in using the underscore?

I think I get it. He doesn't use a variable, as he just has the next section of code happen that many times.
So using underscore is his way to note that.

An underscore is a legal variable name in python.


I think code smell originated from the book "Clean Code" but I am not sure, however now it is a common term now for code that is showing some common design flaw. Not production breaking flaw necessarily but a flaw that could become a bigger issue down the line if you try to develop on top of it. Not all code smells are equal.

1 Like

You got that right.
As Phil said, underscore is a legal name for a variable in python, so you can use it just like any other valid name.
But, being an underscore, it's often used to say "I'm using a variable here but I'm not gonna use it".

Another example (that's python3 though, don't try this with 2.7):
Imagine you want the first and last elements from a list.
You could use

a, *b, c = [1, 2, 3, 4, 5]
# a == 1
# b == [2, 3, 4]
# c == 5

But to show that you only care about the first and last element, you could use an underscore:

first, *_, last = [1, 2, 3, 4, 5]

Languages are not much different from each other, (data structures, conditional statements, repetition loops etc), but I am yet to see a good explanation of JYTHON/JAVA integration. How does it work under the hood! I understood it more from some blogs by enthusiasts but couldn't find a proper explanation in any of the books available freely on internet. How they thought of such an amazing concept! This is the key differentiator and the most interesting and practical aspect of Jython in my opinion. It is not a very obvious concept!

If someone can give me a good reference explaining how JYTON/JAVA integration works under the hood, I would be grateful.

1 Like

I don't know what part is the Java part.

Raymond Hettinger has a really good video on under the hood how the dictionaries evolved that I saw the other day. Modern Dictionaries by Raymond Hettinger - YouTube

At 52 minutes he provides some insight how some sections of Python got developed.

1 Like

You should start with Jython's own site. The Documentation links, in particular. If you really want to know how stuff works, I recommend studying the source code. A strong background in Java is helpful.

It is all open source.

1 Like

Thanks. I should spend some serious time with this to understand it properly.

How often does the version change?

I learned a great deal from those materials when I had a specific task in mind within Ignition. (Jython code modules within my EtherNet/IP Host Device OPC driver, FWIW.)

Not often. It was Jython 2.5.2 and 2.5.3 though the entire v7.x line. Since v8.0, it has been v2.7.1 and then v2.7.2.

Ignition applies a few patches to jython, so it is not an exact match to the download from

This is a good resource, as it uses Python 2 syntax.


Although not a book, I find W3Schools an excellent reference for Python (and also SQL).