Skip to content
0:00 / 0:00

#raymondhettinger#idiomaticpython#pycon

Transforming Code into Beautiful, Idiomatic Python

Next Day Video

68K subscribers • 16 videos on Hallway

YouTube
  • Recommended by 10 people: 9 on Hacker News and 1 curated list.
  • A classic. People kept recommending it from 2014 to 2022.
  • Presented by Raymond Hettinger, Python core developer

Intermediate. Assumes working knowledge.

1M views13 years ago10 recommendations

Programming languagesSoftware designPythonDesign patternsRefactoring and legacy code

Raymond Hettinger demonstrates how to improve Python code by replacing common anti-patterns with clean, idiomatic language features.

Raymond Hettinger Learn to take better advantage of Python's best features and improve existing code through a series of code transformations, "When you see this, do that instead."

Why it's here

10 people recommend this

What people say. Highly recommended as a must-watch talk for learning how to write clean and idiomatic Python code.

Moments people linked to

clusmoreon Hacker News • Recommends

On “Origins of Python's “Functional” Features (2009)”

Must watch: link to this video I believe that the list comprehension will be faster than filter, but as always, any time you replace readable code with unreadable code for performance reasons, you damn well better time it.

bhoetingon Hacker News • Recommends

On “Ask HN: Which programmer do you look up to?”

I've never heard of Raymond Hettinger before but I'm currently watching one of his videos 1 and it's amazing. Thanks for sharing your list, I'll definitely look up some more of these people. 1 link to this video

jkaon Hacker News • Recommends

On “Software engineering topics I changed my mind on”

Your mention of simple and clean code makes me think of the excellent talk "Transforming Code into Beautiful, Idiomatic Python". Although it relates to Python programming, if the ideas and principles (and thoughtfulness and pace) from it could be applied to much more written code, then (I think) we as an industry and all our users would be in a better place. 1 - link to this video

programming-talkscurated list on GitHubRecommends

Under “Python”

Transforming Code into Beautiful, Idiomatic Python 00:48:51 by **Raymond Hettinger** (2013)

kriroon Hacker News • Recommends

On “Python Language Features and Tricks”

Great suggestion. Just searched for him on youtube and a couple of excellent looking talks popped up. Halfway through and this one seems great so far: link to this video Really enjoy his style as well :)

msvalkonon Hacker News • Recommends

On “Anti-Patterns in Python Programming”

Check out Raymond Hettingers Transforming Code into Beautiful, Idiomatic Python talk on youtube 1. Great talk on avoiding some of the common pitfalls new python developers step in. Exposes some nice language features. 1: link to this video

shackenbergon Hacker News • Recommends

On “Python idioms I wish I'd learned earlier”

If you were underwhelmed by this blog post have a look at: Transforming code into Beautiful, Idiomatic Python by Raymond Hettinger at PyCon 2013 link and link to this video Topics include: 'looping' with iterators to avoid creating new lists, dictionaries, named tuples and more

kzrdudeon Hacker News • Recommends

On “Writing Pythonic Rust”

Raymond Hettinger's talks are great. I know it's not a succint blog post, but they are out there are watching a video is very approachable. Maybe link (Dataclasses! We could cheekily say Python gets better at something Rust does - dataclasses makes Python better at records.) And link This talk (2013): link to this video Unfortunately this video is now a bit out of touch with modern Python. Another (2013) classic: link it is very well known, and it has the very memorable advice: what's a class that only has one method? That should be a function!

greggybon Hacker News • Recommends

On “Your users will do what you make easy”

These are a few videos which present Pythonic style. They do not form a proper curriculum, but they are example-heavy and give a good insight to a very Pythonic mind. 1. Beyond PEP 8 link 2. Transforming Code into Beautiful, Idiomatic Python link to this video

mumblemumbleon Hacker News • Recommends

On “Python-patterns – A collection of design patterns/idioms in Python”

For an alternative perspective, allow me to present some classic talks from Raymond Hettinger. First, some generic tips on how to write Python code that's pleasant to work with: link to this video And then this one digs more specifically into how not to write Python like it's Java, starting at 12:40 (with talking about why leading up to that): link

Jabbaon Stack Overflow • Mentions

On “How to properly ignore exceptions”

First I quote the answer of Jack o'Connor from this thread. The referenced thread got closed so I write here: "There's a new way to do this coming in Python 3.4: from contextlib import suppress with suppress(Exception): # your code Here's the commit that added it: http://hg.python.org/cpython/rev/406b47c64480 And here's the author, Raymond Hettinger, talking about this and all sorts of other Python hotness: link to this video My addition to this is the Python 2.7 equivalent: from contextlib import contextmanager @contextmanager def ignored(*exceptions): try: yield except exceptions: pass Then you use it like in Python 3.4: with ignored(Exception): # your code
125View the answer

eddygon Hacker News • Mentions

On “The optional “else” in Python loops”

Glad you posted this. I came to the comments to post the same thing1 because thinking of it as "notfound" makes remembering (and comprehending it) easier. :) 1 link to this video

smt88on Hacker News • Mentions

On “jQuery 3.0 Released”

1) There's certainly not "one way" to iterate in Python1, and they're not even consistently named (xrange is the iterator version of range, but izip is the iterator version of zip). 2) You can use Python in the browser234 sort of. 1. link to this video 2. link 3. link 4. link

jimmytucsonon Hacker News • Mentions

On “Python’s For - Else”

Here’s why (Hettinger): > In 1991, “else” was the obvious choice because of the traditional way compilers implemented while-loops: pastebin.com/tY35CTJ4 That is, “if I haven’t finished the loop, GOTO the body.” He says if he had a time machine he could tell Guido in the future we’re all using structured programming so no one will find “else” intuitive; call it “nobreak” instead: link to this video Guido says if he had a time machine he would not have included the feature at all: link This whole thing was Knuth’s idea, not Guido’s: link

greggybon Hacker News • Mentions

On “A Python Guide for the Ages”

…rtunately, structured programming is the absolute norm now, and we learn looping constructs directly, rather than learning 'goto' and then building to looping constructs. Especially in a language with rich iteration protocols, such as Python, it is very much unapparent that the looping constructs are fancy wrappers around 'goto'. Link to the talk: link to this video…

u/_rowlf_in r/compsci • Mentions

On “Book recommendations”

Certainly no harm in having a goal in mind. Do you mind me also asking how old you are? That might change the recommendations... I would suggest for fundamentals you need to have a full understanding of **Understand Algorithms** Data Structures \-Array \-Stack \-Queue \-Hashtable \-Linked List \-Binary Search Tree \-PriorityQueue Search \-Binary Search Sort \-Bubble Sort \-Selection Sort \-Insertion Sort \-QuickSort \-Merge Sort \-Heap Sort Graphs \-Depth First Search \-Breadth First Search By the time you cover this lot you will know what other topics to start investigating for your self e.g. Recursion, DP, etc.. **Understand how computers work** \-…