Re: Undoing character read from file

2012-02-17 Thread Dave Angel
On 02/17/2012 10:38 PM, Emeka wrote: Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mse

Re: Undoing character read from file

2012-02-17 Thread Emeka
Hello All, Say I have something like this: mfile = open("cc.txt", "rb") mcount = 0 mset = False while True: c = mfile.read(1) if c == "e" and mset is True and mcount == 0: print c mfile.seek(-1,1) mcount = 1 continue elif c == "e" and mset is False and mcount == 0: print c

Re: Undoing character read from file

2012-02-17 Thread Emeka
Neil, Thanks. Could you throw a simple example? Regards, \Emeka On Fri, Feb 17, 2012 at 3:12 PM, Neil Cerutti wrote: > On 2012-02-16, MRAB wrote: > > 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

Re: Undoing character read from file

2012-02-17 Thread Neil Cerutti
On 2012-02-16, MRAB wrote: > 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.s

Re: Undoing character read from file

2012-02-16 Thread MRAB
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 p

Undoing character read from file

2012-02-16 Thread Emeka
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? Regards, \Emeka *Satajanus Nig. Ltd * -- http://mail.python.org/mailman/listinfo/python-list