Equivalent of Perl chomp?
Thomas Bellman
bellman at lysator.liu.se
Sat Feb 2 11:20:19 EST 2002
"Steve Holden" <sholden at holdenweb.com> wrote:
> Perhaps I'm just lazy, but why not process
> for line in file(filename).read().split("\n"):
> under such circumstances?
Because
a) I don't like reading entire files into memory before processing,
when not needed. I'm not very fond of wasting memory. Too many
programs do that already, and I don't feel the need to contribute
to that.
b) It is more complicated to read and understand. 'for line in
fp.xreadlines()' is immediately understandable, while your
variant takes a couple of seconds to understand the full
implications of.
--
Thomas Bellman, Lysator Computer Club, Linköping University, Sweden
"Don't tell me I'm burning the candle at both ! bellman @ lysator.liu.se
ends -- tell me where to get more wax!!" ! Make Love -- Nicht Wahr!
More information about the Python-list
mailing list