'Set the file\'s current position.
The mode argument is optional and defaults to 0 (absolute file
positioning); other values are 1 (seek relative to the current
position) and 2 (seek relative to the file\'s end).
There is no return value.'

def seek(self, pos, mode=0):

    _complain_ifclosed(self.closed)
    if self.buflist:
        self.buf += ''.join(self.buflist)
        self.buflist = []
    if (mode == 1):
        pos += self.pos
    elif (mode == 2):
        pos += self.len
    self.pos = max(0, pos)
