readline()/readlines() inconsistent?

Tim Hammerquist tim at vegeta.ath.cx
Sun Jul 8 23:10:36 EDT 2001


Quinn Dunkan <quinn at retch.ugcs.caltech.edu> wrote:

[ snippage ]
> >BTW, is file.xreadlines() a new feature in Py2.1?
> 
> Yep.
> 
> >Of course, an obvious question is, if you want to read _and_ write, why
> >weren't you using 'r+' or 'w+' to begin with?
> >
> >I hope someone can answer this, but is this a matter of file I/O
> >implementation between different OS's?  Or is this a Python
> >implementation issue?
> 
> Despite what the documentation may say, readlines does not use readline.
> readlines uses fread() (since it doesn't have to worry about reading too much)
> and then checks with ferror().  readline uses getc() (or perhaps fgets()) and,
> when it gets EOF for error, proceeds to *not* check for error (clears it, in
> fact).  So I'd say linux, SunOS, and Irix are correct here and OSX is wrong
> (must not be reporting via ferror() correctly).
> 
> I'd say python is wrong here too, by not being consistent.  If readline
> checks, readlines should too.

Thank you for the excellent answer!  And I agree that Python should be
more consistent.

BTW, I try to have back 1 minor version or so to let the groups debug
the current release (a habit I picked up due to ActiveState's Perl
implementation).  Is Py2.1 stable, or are there still some bugs? Is it
suitable for enterprise development?

Thx in advance,
Tim
-- 
-Tim Hammerquist <timmy at cpan.org>

Ted's got a mind like a steel sieve.
    -- Woody Allen, "Manhattan Murder Mystery"



More information about the Python-list mailing list