Linux endline
Chris Liechti
cliechti at gmx.net
Sat Mar 16 12:40:51 EST 2002
"Fredrik Lundh" <fredrik at pythonware.com> wrote in news:gJKk8.25432
$n4.4999467 at newsc.telia.net:
> Fabien Hénon wrote:
>> 1° When I use it under Linux I would like to get rid of the \r
which
>> appears at the end of each line. ( I know there is a difference of
>> endline between Windows, Mac and Linux).
>
> how about
>
> if line.endswith("\r\n"):
> # deal with DOS file ending
> line = line[:-2] + "\n"
> self.text.insert(END, line)
or, if you don't care about having whitespaces after the last
printable character you can also call line = rstrip(line).
i even use string.strip() in an application where no leading or
trainling whitespaces are needed.
chris
--
Chris <cliechti at gmx.net>
More information about the Python-list
mailing list