Frankenstring
Roland Heiber
newstonne at web.de
Wed Jul 13 03:22:44 EDT 2005
Thomas Lotze wrote:
> It's definitely no help that file-like objects are iterable; I do want
> to get a character, not a complete line, at a time.
Hi,
if i did understand what you mean, what about using mmap? Iterating over
characters in a file like this:
# -*- coding: iso-8859-1 -*-
import os
import mmap
f = open("file.txt", "r+")
size = os.path.getsize("file.txt")
m = mmap.mmap(f.fileno(), size)
for x in m:
print x
m.close()
f.close()
More information about the Python-list
mailing list