❝HN 片单

Raymond Hettinger - Beyond PEP 8 -- Best practices for beautiful intelligible code - PyCon 2015

PyCon 2015 · 13 位 HN 用户推荐 · 2015–2024

Hettinger 讲 PEP 8 之外如何写出地道易读的 Python

  1. A number of these answers are highly unidiomatic, symptoms of people coming from another language to Python. Trying to shoe horn one language's patterns into another is fraught with problems, not only are you going to be less effective in the new language but experienced coders of that language are going to hate working with your code. Raymond Hettinger's PyCon 2015 talk "Beyond PEP 8 -- Best pra
    — hartror, 2015
  2. There's a great talk on this [1] by Raymond Hettinger where he argues that style guides (e.g. PEP8) are no alternative to thinking hard about the code. Blindly following rules (like a bot would do) just gives a false sense of security that it's good code. [1] [link]
    — GrumpySimon, 2015
  3. At first read this is a pretty reasonable doc for some things to consider. I also recommend watching the linked "PEP8" YouTube presentation from PyCON: [link]
    — mpdehaan2, 2016
  4. Beyond PEP 8 - Best practices for beautiful intelligible code [link]
    — ra7, 2016
  5. As for resources, you can already program, so ... Browse the manual (it is quite good), look at some pythonic* style videos* , browse the giant standard library and do some stuff with it... (the last part is key) = yes, that is a genuine keyword, that can be googled and [link] * * = this is good [link]
    — svennek, 2017
  6. You should check out this talk [1] before going around trying to use PEP8's inconsequential clauses to call something "horrible" code. [1] - [link]
    — gravypod, 2017
  7. Yes, just like that. Check out this fantastic talk on being pythonic: [link]
    — TremendousJudge, 2017
  8. Raymond Hettinger talks about this in "Beyond PEP8", which is one of my favorite conference talks [link]
    — dralley, 2021
  9. What does make code "hard to read" are things like bad and inconsistent variable/function/class names, bad inheritance practices, bad file organization, and not adhering to common language idioms. That stuff is rarely, if ever, caught by linters. Great talk by Raymond Hettinger about this: [link]
    — sseagull, 2021
  10. First, some generic tips on how to write Python code that's pleasant to work with: [link] 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]
    — mumblemumble, 2022
  11. All the better if that refactoring is in a FOSS application/library to save other people the repeat effort (and potentially gather further improvements). Your question reminded me of Raymond Hettinger's excellent 2015 PyCon talk about refactoring functional-but-messy Python code: [link]
    — jka, 2022
  12. To follow up on this, if you've got a spare hour, one of the python core developers has a great demo of how pep8 can sometimes be blinding to larger issues [link]
    — wonkyspecs, 2022

← HN 片单