HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

Transforming Code into Beautiful, Idiomatic Python

Next Day Video9 HN recommenders · recommended in 9 months, 2014-2022
YouTube
1.1M views · 13 years ago · talk · dated

Raymond Hettinger's PyCon 2013 talk on transforming code into idiomatic Python through a series of before-and-after refactorings. It shows how to use iterators, dictionaries, named tuples and other language features well.

HN treats it as a must-watch classic for writing Pythonic code, though somewhat dated for modern Python.

Python, Ruby & scripting languagesSoftware practice, open source & careers#python#raymondhettinger#pycon#refactoring#bestpractices

13 comments from Hacker News

@mumblemumble2022 · in “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: ▶ 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

RecommendsView on HN
@greggyb2021 · in “A Python Guide for the Ages”

Raymond Hettinger has a good section on this, tracing it back Knuth's discourse on structured programming in the face of 'goto'. He suggests calling the keyword 'nobreak', rather than 'else'. Inside any loop are a conditional and a jump. In pseudocode: if not <loop end condition> then <do loop things> <jump to top of loop> else //loop is done <do things in the case that the loop has terminated naturally> If we 'break' in the body of the loop for some reason, we will never hit the 'else' in this chunk of code. As Mr. Hettinger explains, this is obvious to anyone reading Knuth or coming from a 'goto' style of control flow. This is not an insult, but an observation. (Un)Fortunately, 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: ▶ this video

CitesView on HN
@greggyb2021 · in “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 ▶ this video

RecommendsView on HN
@kzrdude2021 · in “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): ▶ 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!

RecommendsView on HN
@jka2021 · in “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] - ▶ this video

Strongly recommendsView on HN
@jimmytucson2018 · in “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: ▶ 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

CitesView on HN
@bhoeting2017 · in “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] ▶ this video

Strongly recommendsView on HN
@clusmore2017 · in “Origins of Python's “Functional” Features (2009)”

Must watch: ▶ 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.

Strongly recommendsView on HN
@smt882016 · in “jQuery 3.0 Released”

1) There's certainly not "one way" to iterate in Python[1], 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 browser[2][3][4 sort of]. 1. ▶ this video 2. link 3. link 4. link

CitesView on HN
@shackenberg2014 · in “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 ▶ this video Topics include: 'looping' with iterators to avoid creating new lists, dictionaries, named tuples and more

RecommendsView on HN
@eddyg2014 · in “The optional “else” in Python loops”

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

CitesView on HN
@msvalkon2014 · in “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]: ▶ this video

RecommendsView on HN
@kriro2014 · in “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: ▶ this video Really enjoy his style as well :)

RecommendsView on HN
Raymond Hettinger - Dataclasses:  The code generator to end all code generators - PyCon 201845:08

Raymond Hettinger - Dataclasses: The code generator to end all code generators - PyCon 2018

PyCon 2018
130K views • 8 years ago
The Mental Game of Python - Raymond Hettinger1:10:00

The Mental Game of Python - Raymond Hettinger

SF Python
131K views • 7 years ago
The Mental Game of Python - Raymond Hettinger [synced version]1:10:00

The Mental Game of Python - Raymond Hettinger [synced version]

Tech Ma
24K views • 6 years ago
Keynote - Preventing, Finding, and Fixing Bugs On a Time Budget | Raymond Hettinger @ PyBay201840:01

Keynote - Preventing, Finding, and Fixing Bugs On a Time Budget | Raymond Hettinger @ PyBay2018

SF Python
27K views • 8 years ago
Modern Dictionaries by Raymond Hettinger1:07:41

Modern Dictionaries by Raymond Hettinger

SF Python
150K views • 9 years ago
A Talk Near the Future of Python (a.k.a., Dave live-codes a WebAssembly Interpreter)1:01:45

A Talk Near the Future of Python (a.k.a., Dave live-codes a WebAssembly Interpreter)

David Beazley
26K views • 7 years ago
Raymond Hettinger, Keynote on Concurrency, PyBay 20171:13:53

Raymond Hettinger, Keynote on Concurrency, PyBay 2017

SF Python
161K views • 9 years ago
David Beazley - Lambda Calculus from the Ground Up - PyCon 20193:26:34

David Beazley - Lambda Calculus from the Ground Up - PyCon 2019

PyCon 2019
52K views • 7 years ago
Google Developers Day US - Python Design Patterns44:03

Google Developers Day US - Python Design Patterns

GoogleDeveloperDay
90K views • 19 years ago
What nobody tells you about documentation30:52

What nobody tells you about documentation

PyCon AU
105K views • 9 years ago
Stop Writing Classes27:29

Stop Writing Classes

Next Day Video
962K views • 14 years ago
Build Your Own Async2:12:42

Build Your Own Async

David Beazley
60K views • 7 years ago
"Hedy: A Gradual programming language" by Felienne Hermans (Strange Loop 2022)40:57

"Hedy: A Gradual programming language" by Felienne Hermans (Strange Loop 2022)

Strange Loop Conference
17K views • 4 years ago
Google Python Class Day 1 Part 151:37

Google Python Class Day 1 Part 1

Google for Developers
3.7M views • 16 years ago
Friday evening lightning talks52:24

Friday evening lightning talks

Next Day Video
6K views • 13 years ago
Q&A with Guido van Rossum, Inventor of Python56:55

Q&A with Guido van Rossum, Inventor of Python

Microsoft Reactor
28K views • 5 years ago
Compiling and Optimizing Scripting Languages1:01:37

Compiling and Optimizing Scripting Languages

Google TechTalks
21K views • 17 years ago
RailsConf 2014 - Keynote: Writing Software by David Heinemeier Hansson1:01:17

RailsConf 2014 - Keynote: Writing Software by David Heinemeier Hansson

Confreaks
123K views • 12 years ago
Hillel Wayne - Beyond Unit Tests: Taking Your Testing to the Next Level - PyCon 201829:21

Hillel Wayne - Beyond Unit Tests: Taking Your Testing to the Next Level - PyCon 2018

PyCon 2018
38K views • 8 years ago
James Powell: So you want to be a Python expert? | PyData Seattle 20171:54:11

James Powell: So you want to be a Python expert? | PyData Seattle 2017

PyData
508K views • 9 years ago