Re: Good Python style?



Steven D'Aprano wrote:

It would probably be easier to read with more readable names and a few
comments:

[...]

Splitting it into multiple lines is self-documenting:

blankless_lines = filter(None, [line.strip() for line in input_lines])
first_words = [line.split()[0] for line in blankless_words]
some_set = frozenset(first_words)

Re-writing code so that it is self-documenting is almost always a better approach. Premature optimization is the root of all evil.
--
Michael Hoffman
.



Relevant Pages

  • Optimized quoting (was Re: Speed?)
    ... If Knuth is God, ... "Premature optimization is the root of all evil in programming." ...
    (comp.lang.python)
  • Re: How to get imagebase after a DLL gets loaded
    ... Hardcoding the DLL's name is a far too brittle option for me. ... Premature optimization is the root of much evil. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: assembly optimization.?
    ... all evil " Knuth. ... Actually, Sir Tony Hoare said it, Knuth simply repeated it often enough ... premature optimization is the root of all evil." ...
    (alt.lang.asm)
  • Re: Is a "real" C-Python possible?
    ... Donald Knuth, one of the fathers of modern computer science, is famous ... "Premature optimization is the root of all evil in programming." ...
    (comp.lang.python)
  • Re: Fork or threads
    ... Premature optimization is the root of all evil. ... Create code first that is simple to write and natural to read. ...
    (comp.unix.programmer)