Good Python style?

Michael Hoffman cam.ac.uk at mh391.invalid
Thu May 31 06:59:48 EDT 2007


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



More information about the Python-list mailing list