[Python-Dev] xreadlines : readlines :: xrange : range

Paul Prescod paulp@ActiveState.com
Tue, 02 Jan 2001 15:26:39 -0800

Guido van Rossum wrote:
> ...
> I'm slowly warming up to xreadlines(), although we must be careful to
> consider the consequences (do other file-like objects need to support
> it too?).

The implementation is such that it is pretty easy to add the method to
other file-like objects. It is also easy to use the xreadlines module to
get the same behavior for objects that do not have the method. 
Essentially, file.xreadlines is implemented like this:

def xreadlines(self):
    import xreadlines

Any object can add the method similarly.

 Paul Prescod