'Seek to a position in the file.'

def seek(self, pos, whence=os.SEEK_SET):

    if self.closed:
        raise ValueError('I/O    operation    on    closed    file')
    if (whence == os.SEEK_SET):
        self.position = min(max(pos, 0), self.size)
    elif (whence == os.SEEK_CUR):
        if (pos < 0):
            self.position = max((self.position + pos), 0)
        else:
            self.position = min((self.position + pos), self.size)
    elif (whence == os.SEEK_END):
        self.position = max(min((self.size + pos), self.size), 0)
    else:
        raise ValueError('Invalid    argument')
    self.buffer = ''
    self.fileobj.seek(self.position)
