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...

class InputStream(Stream):
   def read(self): # Reads 1 byte
       return os.stdin.read(1)
  
   def readline(self):
       ret = self.readrec('\n') # or whatever constant represents the EOL
       return ret

class Stream(object):
   def read(self):
       raise Exception, 'cannot read'

   def readrec(self,terminator):
       ret = ''
       while ret != terminator: ret = ret + self.read()
       return ret

   def write(self):
       raise Exception, 'cannot write'
  
   def writeRec(self, terminator):
       ''' writeRec returns self as a list split by terminator '''
       ret = str(self)
       return str(ret).split(terminator)
--
Cheers,
Hasan Diwan < [EMAIL PROTECTED]>
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to