Equivalent of Perl chomp?

A Meowbot meowbot at meowing.net
Thu Jan 31 17:09:09 EST 2002


Erno Kuusela <erno-news at erno.iki.fi> wrote:

> in dos text mode, all cr-lf sequences are translated into lf upon
> reading and lf into cr-lf upon writing, at file i/o time. unless you
> are using binary mode, in which no translation is done. so even in
> dos, the strings you have in memory always end in lf (when read from a
> file opened in text mode).

Where things get yucky is when you are reading a Microsoft-formatted
file or a network stream under Unix, where there is no difference
between text and binary.  It's for those all-too-common cases that
both line endings need to be taken into account.

I don't even want to talk about the Apple CR thing.




More information about the Python-list mailing list