30 Sep
2011
30 Sep
'11
4 p.m.
On Fri, 30 Sep 2011 07:28:19 -0400 Nick Coghlan <ncoghlan@gmail.com> wrote:
On Fri, Sep 30, 2011 at 5:42 AM, Giampaolo RodolĂ <g.rodola-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
...or 2 in case you're not at the beginning of the file. before = f.tell() f.peeklines(10) f.seek(before)
A context manager to handle the tell()/seek() may be an interesting and more general purpose idea:
But it still only works on seekable streams. Some time ago I proposed a general prefetch() method that would allow easy protocol-specific buffering on top of non-seekable streams, but there didn't seem to be a lot of enthusiasm at the time: http://mail.python.org/pipermail/python-ideas/2010-September/008179.html Regards Antoine.