HN Hall of Fame Weekly email

WTFPython: Exploring and understanding Python through surprising snippets

Screenshot of github.com captured 2026-07-20
Page preview · captured 2026-07-20

Resurfaced independently across 8 calendar years, with breakout response in 3 of them.

submissions
14
submitters
13
observed span
2017–2025
peak thread · 162 comments
460 pts
latest 20+ return · 2023-08-27
251 pts

Submission timeline

2007–2026

One slot for every year since HN launched. Height is that year's peak points; orange marks a 100+ point or 50+ comment breakout. Select a bar to open its strongest thread.

First comments on top threads

HN comment order

I have a mildly surprising snippet which I believe they don't have. It's about interaction of class and instance attributes with behavior of "X += Y". Python expands it to "X = X + Y" but only if X implements "+" but not "+=" class A: a = (1,) # tuples are immutable and don't have "+=" b = [1,] # lists have "+=" obj = A() obj.a += (2,) # this creates obj.a obj.b += (2,) # this modifies…

praptak·460-point thread·

I feel like WTFs caused by doing something deeply weird hardly counts against the language. Yes doing the walrus operator inside brackets works. Yes of course it's going to be doing weird things. Is this really surprising to anyone? It's not what that operator is for. Yes comparing strings with "is" works sometimes. It's not checking equality and it isn't supposed to. In another implementation using "is" might work all the time or none of the time. Don't use "is"…

Doxin·359-point thread·

Auch. Quite a few of these stem from the design mistake to allow cross-type equality tests combined with a hard headed effort to try to make it work. >>> 2 == 2L True >>> hex(2) == hex(2L) False >>> type(2) <type 'int'> >>> type(2L) <type 'long'> >>>

There are some good ones in there! I especially like that explanations are given and the optimizations that CPython makes are revealed.

The first top-level comment from each of the four biggest threads, in HN’s own order. Excerpts are shortened; open a comment for full context.

Breakout years
3

100+ points or 50+ comments

Total points
1132

reference only — not used in Hall rules or ranking

Total comments
396

reference only — not used in Hall rules or ranking

Every submission