Reading text files where last line has no EOL
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Sep 17 15:20:19 EDT 2007
En Mon, 17 Sep 2007 09:02:38 -0300, BlueBird <phil at freehackers.org>
escribi�:
> Oooooooops. It was a stupid bug in my script: textLine[:-
> int(textLine[-1]=='\n')] is not what I want (the real code was not a
> one-liner)! The documentation made me think that something wrong was
> going on with python but I should have known better.
If that expression is supposed to remove the trailing newline, I suggest
using
textLine = textLine.rstrip('\n')
--
Gabriel Genellina
More information about the Python-list
mailing list