Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20528

Re: Undoing character read from file

Date 2012-02-16 23:31 +0000
From MRAB <python@mrabarnett.plus.com>
Subject Re: Undoing character read from file
References <CAOypoo53NuLCfju_YuYh6AHR4g0GuN=EbKnmh7KY-3nxbaOSLg@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5904.1329435244.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 16/02/2012 23:10, Emeka wrote:
> Hello All,
>
> I know about seek and tell while using readline. What about if I am
> using read, and I want to undo the last character I just read(to return
> it back to the stream). How do I achieve this?
>
Try:

     f.seek(-1, 1)

It seeks -1 relative to the current position (the second argument
defaults to 0 for relative to start of file).

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Undoing character read from file MRAB <python@mrabarnett.plus.com> - 2012-02-16 23:31 +0000
  Re: Undoing character read from file Neil Cerutti <neilc@norwich.edu> - 2012-02-17 13:12 +0000
    Re: Undoing character read from file Dave Angel <d@davea.name> - 2012-02-17 22:58 -0500

csiph-web