Reading text files where last line has no EOL

Gabriel Genellina gagsl-py2 at
Mon Sep 17 21:20:19 CEST 2007

En Mon, 17 Sep 2007 09:02:38 -0300, BlueBird <phil at>  

> 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  
textLine = textLine.rstrip('\n')

Gabriel Genellina

More information about the Python-list mailing list