support 'whence' arg to seek()

This commit is contained in:
Guido van Rossum 1996-01-25 18:40:41 +00:00
parent 0eaa74bf8d
commit 44a4d59b56
1 changed files with 7 additions and 2 deletions

View File

@ -12,8 +12,13 @@ class _Mailbox:
self.fp = fp self.fp = fp
self.seekp = 0 self.seekp = 0
def seek(self, pos): def seek(self, pos, whence=0):
self.seekp = pos if whence==1: # Relative to current position
self.pos = self.pos + pos
if whence==2: # Relative to file's end
self.pos = self.stop + pos
else: # Default - absolute position
self.pos = self.start + pos
def next(self): def next(self):
while 1: while 1: