ungetc in Python
Posted
by Dragos Toader
on Stack Overflow
See other posts from Stack Overflow
or by Dragos Toader
Published on 2010-04-16T19:32:09Z
Indexed on
2010/04/16
19:33 UTC
Read the original article
Hit count: 463
Some file read (readlines()) functions in Python
copy the file contents to memory (as a list)
I need to process a file that's too large to
be copied in memory and as such need to use
a file pointer (to access the file one byte
at a time) -- as in C getc().
The additional requirement I have is that
I'd like to rewind the file pointer to previous
bytes like in C ungetc().
Is there a way to do this in Python?
Also, in Python, I can read one line at a
time with readline()
Is there a way to read the previous line
going backward?
© Stack Overflow or respective owner