
Ask HN: What's the best source to learn idomatic Python? - alfiedotwtf
Long story short, I&#x27;m coming from 15 years of Perl but now trying to pick up Python. I want to do it the right may (best practices) rather than hack my way in, so was wanting the best (and up-to-date) guide on idiomatic Python.<p>Any suggestions?
======
sndean
I went through "Fluent Python: Clear, Concise, and Effective Programming" and
think it's probably the best Python (or any programming language?) book I've
tried.

Not sure if a book is what you meant by guide.

~~~
alfiedotwtf
Yep, I've been on Amazon for the past hour, and this looks good. Thanks!

~~~
mayankkaizen
Fluent Python is the best intermediate level Python book I have read. It is
one book you wish to have more and more pages.

~~~
alfiedotwtf
Thanks for the confirmation :) Added to my shopping list!

------
Jugurtha
The Python documentation is pretty cool. I frequently go to Chapter 3 (Data
Model) and always learn something new reading something I had already read but
didn't quite get.

The mailing list has top notch posters who are always willing to help.

The IRC channel (#python) has very helpful members who've been patient with me
on more than one occasion.

Books:

Stacking the deck:

"Python Guide" \- Kenneth Reitz: The bits one doesn't necessarily think about
but that simplify life: virtual environments, unit test, project structure,
good practices, scenarios for different kinds of applications, documentation,
etc.

Doing stuff:

"Python Cookbook" (several editions by different authors, Alex Martelli and
David Beazley): as the title states, it's a cookbook that shows you how to do
a bunch of stuff in Python (files, network, threads, etc). This can get you
"operational" in Python pretty fast.

Doing stuff well (meta):

" _Writing Idiomatic Python_ " \- Jeff Knupp:

The book comes for Python 2 and Python 3 and contrasts "harmful" and "good".
Jeff Knupp also has videos showing you the process of refactoring code. He
also has a blog ([https://jeffknupp.com/](https://jeffknupp.com/)) where he
addresses many topics.

" _Effective Python: 59 Specific Ways to Write Better Python_ " \- Brett
Slatkin: Pretty good book. The subtitle says it all: 59 specific ways to write
better Python. (600 + pages).

" _Learn Python the Hard Way_ " \- Zed Shaw: I've read that starting out in
Python. Maybe not for a 15 year Perl veteran, but this is for memo.

There's certainly some overlap in these books, but it helps to repeat a
message to understand the importance of something, or to drive a point home. I
didn't use virtual environments until the message was repeated enough in
different ways.

Pornography:

PyCon talks. A lot of these are great.

David Beazley (a bunch of talks that are pretty cool. Still haven't finished
the ones on generators but they're very good).

Brandon Rhodes (on aesthetics and design patterns (or lack thereof), and
testing web applications).

Kenneth Reitz on design.

Raymond Hettinger (you'll find "Writing Beautiful Idiomatic Python" and
"Beyond PEP8" most helpful).

~~~
vram22
Seconding the recommendation for the Python Cookbooks (by O'Reilly). I have
both the Py 2 and Py 3 versions. I've read the 2 book (multiple authors)
pretty much fully (and much of it more than once), except for a few more
advanced recipes, or areas that I was not that interested in, and found it
really good. Used some of the ideas and techniques in some production code.
The chapter in it on iterators and generators is particularly good (some of
the stuff in it is by Raymond Hettinger, who also, IIRC, designed and
implemented much of the iterator and generator functionality in Python 2).
I've only read parts of my copy of 3 so far, but it is good too, though the
style is somewhat different. It is more brief (per recipe, though the book
overall is as large or larger than 2), and you have to do more work yourself
to understand the recipes. The authors explicitly say this.

------
clusmore
Check out Raymond Hettinger's talks on YouTube. Here's one to get you started:
[https://youtu.be/OSGv2VnC0go](https://youtu.be/OSGv2VnC0go)

~~~
vram22
Another good Python video is Ned Batchelder's "Loop like a Native". Has _lots_
of examples of non-idiomatic vs. idiomatic ways of looping in Python. Google a
bit before reading, there may be more than one video, or a blog post and a
video. Check for the latest one etc.

------
vram22
It is probably somewhat out of date now (w.r.t. to new language and library
features of Python), but David Goodger's site also has a list of idiomatic
Python topics; had read it a while ago. This is it:

[http://python.net/~goodger/projects/pycon/2007/idiomatic/han...](http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html)

~~~
alfiedotwtf
Yep, that was one of the first things I found. Will be going through this ASAP

------
mjhea0
[https://jeffknupp.com/writing-idiomatic-python-
ebook/](https://jeffknupp.com/writing-idiomatic-python-ebook/)

~~~
alfiedotwtf
Purchased. Thanks!

------
amirouche
Look up interview questions on the web, I find them very useful to get an idea
of what makes good python programming. I have none to recommend in particular.

~~~
alfiedotwtf
Didn't think of that. Out of the box... nice

------
codegladiator
[https://www.learnpythonthehardway.org/](https://www.learnpythonthehardway.org/)

~~~
alfiedotwtf
Ooh. I don't know if I have the time

