Some Python 2.1 ideas
Thomas Wouters
thomas at xs4all.net
Sun Dec 24 15:07:42 EST 2000
On Sun, Dec 24, 2000 at 12:24:13PM -0700, Bjorn Pettersen wrote:
> Greg Jorgensen wrote:
> > "Bjorn Pettersen" <pbjorn at uswest.net> wrote in message
> > [snip]
> > How should these be handled?
> > "foo\n\n\n"
> > "foo\n\r\n\r"
>
> "foo\n\n\n" -> "foo\n\n"
> "foo\n\r\n\r" -> "foo\n\r"
Note that the latter was a trick question! The proper order for DOS-EOL is
'\r\n', *not* '\n\r'. So the string "foo\n\r\n\r" is a Macintosh string, not
a DOS one :-)
> > Wouldn't it be cleaner to enhance the file object with additional
> > methods:
> >
> > f. readline_chomp()
> > f.readlines_chomp()
> This would be a good idea, except it wouldn't fit with the standard Python idiom
> for reading files:
And everything that poses as a file object would have to duplicate those
functions, all of a sudden. Guido is pretty conservative in adding
conveniency functions to builtin (and oft-imitated) objects because of that.
--
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list
mailing list