Hello. I've not been able to use cStringIO since I have the need to ensure that the memory buffers created are bounded within a resonable limit set by specifications. No, this code does not properly belong in my application as the modules that use "files" should not have to care about any resource limitations that may be imposed.
class LimitedBuffer(StringIO): def __init__(self, buffer = None, maxsize = 5 * 1000 * 1000): StringIO.__init__(self,buffer) self.cursize = 0 self.maxsize = maxsize def write(self,str): self.cursize += len(str) if self.cursize > self.maxsize: raise IOError("allocated buffer space exceeded") return StringIO.write(self,str) Kind Regards, Clark Evans -- http://mail.python.org/mailman/listinfo/python-list