>jay graves wrote:
>> see StringIO or cStringIO in the standard library.

> Just as with files, iterating over them returns whole lines, which is
> unfortunately not what I want.


Then why not subclass it and alter the iteration scheme to do a read(1)
or something?

from StringIO import StringIO


class FrankenString(StringIO):
        lastidx = 0
        atEnd = False
        def __iter__(self):
                while not self.atEnd:
                        char =  self.read(1)
                        idx = self.tell()
                        if self.lastidx == idx:
                                self.atEnd = True
                        self.lastidx = idx
                        yield char

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to