[Python-3000] iostack, second revision
hasan.diwan at gmail.com
Fri Sep 8 02:41:30 CEST 2006
I was thinking about the new IOStack and could not come up with an use case
requiring both a line-oriented and a record-oriented read/write
functionality -- the general case is the record-oriented, lines are just
new-line terminated records. Perhaps this has already been dropped, but I
seem to recall the original spec having a readrec, writerec? Similarly,
readline/writeline aren't needed. For example...
def read(self): # Reads 1 byte
ret = self.readrec('\n') # or whatever constant represents the EOL
raise Exception, 'cannot read'
ret = ''
while ret != terminator: ret = ret + self.read()
raise Exception, 'cannot write'
def writeRec(self, terminator):
''' writeRec returns self as a list split by terminator '''
ret = str(self)
Hasan Diwan <hasan.diwan at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-3000