[Python-3000] Reverse file iteration patch updated
Oleg Broytmann
phd at phd.pp.ru
Mon Dec 10 07:28:01 CET 2007
On Mon, Dec 10, 2007 at 07:12:54PM +1300, Greg Ewing wrote:
> Mark Russell wrote:
> > I posted a patch (http://bugs.python.org/issue1677872) a while ago to
> > add support for reverse iteration through text files - i.e. making
> > this work:
> >
> > for line in reversed(open(path)):
> > print line
>
> If this involves hacking reversed() to give it special
> knowledge of files, I'm not sure it's the best place
> to put it.
It adds a method __reversed__() to class io.TextIOWrapper:
http://bugs.python.org/file8902/reverse-file-iterator-20071209.diff
Looks good for me.
Oleg.
--
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-3000
mailing list