Neil,<div><br></div><div>Thanks. Could you throw a simple example?</div><div><br></div><div>Regards, \Emeka<br><br><div class="gmail_quote">On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti <span dir="ltr"><<a href="mailto:neilc@norwich.edu">neilc@norwich.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 2012-02-16, MRAB <<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>> wrote:<br>
> On 16/02/2012 23:10, Emeka wrote:<br>
</div><div class="im">>> Hello All,<br>
>><br>
>> I know about seek and tell while using readline. What about if I am<br>
>> using read, and I want to undo the last character I just read(to return<br>
>> it back to the stream). How do I achieve this?<br>
>><br>
</div><div class="im">> Try:<br>
><br>
> f.seek(-1, 1)<br>
><br>
> It seeks -1 relative to the current position (the second<br>
> argument defaults to 0 for relative to start of file).<br>
<br>
</div>Unless it's a stream opened in binary mode this will not work.<br>
You'd need to maintain a n-character length buffer instead, with<br>
n being the maximum number of characters you'd like to be able to<br>
put back.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Neil Cerutti<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><i>Satajanus Nig. Ltd<br><br><br></i><br>
</div>