]> granicus.if.org Git - python/commitdiff
support 'whence' arg to seek()
authorGuido van Rossum <guido@python.org>
Thu, 25 Jan 1996 18:40:41 +0000 (18:40 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 25 Jan 1996 18:40:41 +0000 (18:40 +0000)
Lib/mailbox.py

index 8a54b46ea062de2129007b077f1d4e413fea508b..e60b73b966af6197993857b6b881a108ad7ae554 100755 (executable)
@@ -12,8 +12,13 @@ class _Mailbox:
                self.fp = fp
                self.seekp = 0
 
-       def seek(self, pos):
-               self.seekp = pos
+       def seek(self, pos, whence=0):
+               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):
                while 1: