Stripping new lines from strings?
Dennis Lee Bieber
wlfraed at ix.netcom.com
Thu Aug 24 01:28:42 EDT 2000
More information about the Python-list mailing list
Thu Aug 24 01:28:42 EDT 2000
- Previous message (by thread): Stripping new lines from strings?
- Next message (by thread): Newbie question re: decompiling python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 23 Aug 2000 10:44:55 -0700, Bill Spears <bspears at mail.teleport.com> declaimed the following in comp.lang.python: > > > CHRIS wrote: > > > ajung at suxers.de wrote: > > > > > > > > From what I understand of Python file I/O, there is no guarantee that > > returned lines all contain new lines characters so, it may clip the last > > line's ending character. And even then, if it is used on a Windows file, > > it would skip the '\r' character. > > > > Are you sure about this? I thought the idea of reading a line is that you > got a line, i.e. it has \n on the end. And I believe that the conversion > from file \r\n to \n is supposed to be automatic. I guess maybe the last > line in the file could be missing an end of line marker. > Pardon the complete quoting, but since I'm replying to both... From the library reference manual I can extract that readline() (and by evaluation, readlines()) keeps the newline character. A file may, however, not contain a newline on the last line. It does NOT "clip the last line's ending character". The key point is: an empty (but not EOF) line of data results in a string with a newline character. EOF results in an EMPTY string. -- > ============================================================== < > wlfraed at ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG < > wulfraed at dm.net | Bestiaria Support Staff < > ============================================================== < > Bestiaria Home Page: http://www.beastie.dm.net/ < > Home Page: http://www.dm.net/~wulfraed/ <
- Previous message (by thread): Stripping new lines from strings?
- Next message (by thread): Newbie question re: decompiling python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list