
Python Cookbook
by Alex Martelli, David Ascher, David M. Beazley, Brian K. Jones · first published 2002
53% recommend44% neutral3% critical
Why HN recommends it
Recipe-based tour of idiomatic Python that shows how experienced Pythonistas solve common problems through working code. Suits intermediate and advanced programmers who learn from examples rather than syntax reference.
Summarised by Claude from recommending comments
Portable, powerful, and a breeze to use, Python is the popular open source object-oriented programming language used for both standalone programs and scripting applications. It is now being used by an increasing number of major organizations, including NASA and Google. Updated for Python 2.4, The Python Cookbook, 2nd Edition offers a wealth of useful code for all Python programmers, not just advanced practitioners. Like its predecessor, the new edition provides solutions to problems that Python programmers face everyday. It now includes over 200 recipes that range from simple tasks, such as wo
Affiliate links. As an Amazon Associate I earn from qualifying purchases.








…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…
on “Ask HN: What's the best source to learn idomatic Python?” ↗…Google's python course, as it is geared toward python devs working at Google. The course teaches Python 2, and goes against widely accepted guidelines such as PEP-8. I highly recommend David Beazley's Python Cookbook (https://www.dabeaz.com/cookbook.html) for the most idiomatic and comprehensive introduction to Python.
on “Ask HN: How did you learn python?” ↗…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…
on “Ask HN: Catching Up with Python – Resources?” ↗…guides http://www-inst.eecs.berkeley.edu/~selfpace/cs9honline/ to good feedback for an introduction to python and programming in general, while myself mostly relying on the books by Alex Martelli (Python in a Nutshell and Python Cookbook)
on “What did you use to teach yourself Python?” ↗If you know a little Python, I recommend the Python Cookbook by Alex Martelli http://www.amazon.com/Python-Cookbook-Alex-Martelli/dp/05960... It is completely different from other types of books which are either references or tutorials which build some kind of…
on “Ask HN: Good Programming Books to Teach Programmers New Languages?” ↗I recommend The Python Cookbook: http://oreilly.com/catalog/9780596001674. It's not a reference in the sense that it shows you the language syntax or tells you the details of the standard library, but it shows how experienced Pythonistas…
on “Ask HN: ______ is to Python as K&R is to C?” ↗…of recommended online Python tutorials, in order from introductory to more advanced (http://www.quora.com/How-can-I-learn-to-program-in-Python/an...). It also includes my dead-trees recommendation -- "Python Cookbook," by Alex Martelli.
on “Ask HN: ______ is to Python as K&R is to C?” ↗I liked the latest edition of "Python Cookbook" by Beazley and Jones for precisely this.
on “Unicode in Python 3” ↗…manual (a MUST), write some programs, and read some other people's programs. Python is a simple language. Reading other people's programs is a good way to apprentice when learning a new language. The Python Cookbook(s) and the 3rd edition of Python in a Nutshell make good reading. Python comes in two variations these days: Python2 and Python3. Python3 would be the best choice for a new learner.
on “Ask HN: Python?” ↗…we can reduce it to first case by building two triangles and constructing angle between hypotenuses. Useful links: https://en.wikipedia.org/wiki/Farey_sequence https://www.oreilly.com/library/view/python-cookbook/0596001... - python implementation of search in Farey sequence.
on “60-degree angles on a lattice” ↗…so many examples of functioning code was very beneficial. Quick sidebar: if you're looking for an intermediate/advanced-level book with a similar style of pedagogy, I can't recommend highly enough The Python Cookbook by David Beazley. There are recipes in that book that I'm quite honestly unsure how I would function without. And to the credit of the author, every code example functions as a complete, minimal, working…
on “Fundamentals of Python Programming [pdf]” ↗Such an amazing talk ! Someone linked to this on HN a while back, this allowed me to discover David Beazley. I then got the Python Cookbook, and watched a bunch of other very cool talks. He's an excellent speaker and python wizard!
on “Bored? How about trying a Linux speed run?” ↗If you consider yourself a good programmer, read the official reference documentation. A good book was Essential Reference by Beazley but I don't think it was updated for Python3 yet. Also perhaps Python Cookbook. A major part of any language is knowing the standard library(-ies).
on “Ask HN: Which book would you recommend for learning Python in detail?” ↗…though maybe not of the same kinds that you describe, i.e. may not be at machine language level. Tim Peters did a lot of that, per what I read, though others may have too. [1] Think I read it in the Python Cookbook, 2nd Edition, which is a very good book, BTW.
on “Ask HN: What's the most elegant piece of code you've seen?” ↗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!
on “Understanding Python through its builtins” ↗