mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
support 'whence' arg to seek()
This commit is contained in:
parent
0eaa74bf8d
commit
44a4d59b56
1 changed files with 7 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue