Skip to content
DevMeme
290 of 7590
CodeQuality Post #347 · source on Telegram

Pythonic Obfuscation vs. Readable Code

Description

A two-part, hand-drawn comic in the style of xkcd, comparing a 'non-native' and a 'native' programmer. On the left, a stick figure labeled 'non-native' says, '- Sorry for my bad English, it's not my mother tongue'. Below this, there is a clear, multi-line Python 2 code snippet creating nested generators: `foos = (i for i in xrange(10))`, `bars = (j for j in foos)`, `bazs = (k for k in bars)`. On the right, a second stick figure labeled 'native' casually replies, '- LOL ITS OKEY'. Below this is a single, convoluted, and unreadable Python generator expression: `(x for x in xs for xs in ys for ys in lst)`. The humor stems from the irony: the non-native speaker, despite being apologetic about their English, writes code that is far more readable and maintainable. The 'native' programmer, meanwhile, writes code that is technically compact but practically indecipherable, satirizing the tendency in some programming communities to favor overly 'clever' or dense one-liners over clarity, which goes against the core philosophy of Python (the Zen of Python)

Comments

8
Anonymous ★ Top Pick The native speaker's code is so 'pythonic' it's basically a write-only file. It's a great way to guarantee job security, because you'll be the only one who can ever touch it again
  1. Anonymous ★ Top Pick

    The native speaker's code is so 'pythonic' it's basically a write-only file. It's a great way to guarantee job security, because you'll be the only one who can ever touch it again

  2. Anonymous

    Relax about your English; it’s his comprehension that rebinds xs inside xs inside xs - syntax checkers forgive grammar, PagerDuty doesn’t forgive 3 AM stack traces

  3. Anonymous

    The developer who apologizes for their English writes documentation that actually explains what the code does, while the native speaker's PR description just says "refactored stuff" with seventeen nested ternaries that would make a LISP programmer weep

  4. Anonymous

    The non-native speaker lints their grammar; the native ships 'ITS OKEY' straight to prod - and it still passes review because it parses

  5. Anonymous

    The real tragedy here isn't the spelling - it's that the 'native' developer's comprehension is so broken it wouldn't even raise a SyntaxError, it would just make the interpreter weep. Meanwhile, the non-native speaker wrote perfectly idiomatic Python 2.x code that any senior dev would approve in code review. Proof that fluency in English and fluency in Python are orthogonal skills - though both communities will roast you for using deprecated syntax

  6. Anonymous

    If your Python comprehension shadows xs and ys across three fors and still fits on one line, you’re not clever - you’re negotiating a lifetime maintenance contract

  7. Anonymous

    Don’t apologize for your English - apologize for the list comprehension that shadows x, xs, and ys into an accidental O(n³) Cartesian product. PEP 8 never said “LOL ITS OKEY.”

  8. Anonymous

    Non-natives fret over English; natives make for...in loops that even the prototype can't parse

Use J and K for navigation