Re: Good Python style?
- From: Michael Hoffman <cam.ac.uk@xxxxxxxxxxxxx>
- Date: Thu, 31 May 2007 11:59:48 +0100
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
.
- References:
- Good Python style?
- From: Andreas Beyer
- Re: Good Python style?
- From: Steven D'Aprano
- Good Python style?
- Prev by Date: Re: speeding things up with C++
- Next by Date: Re: replace the base class
- Previous by thread: Re: Good Python style?
- Next by thread: Re: Good Python style?
- Index(es):
Relevant Pages
|