def read_text(self, encoding=None, errors=None):
    """
    Open the file in text mode, read it, and close the file.
    """
with self.open(mode='r', encoding=encoding, errors=errors) as f:
    return f.read()
Reading entire file in Python