'Flush the file and close it.
A closed file cannot be written any more. Calling
:meth:`close` more than once is allowed.'

def close(self):

    if (not self._closed):
        self.__flush()
        object.__setattr__(self, '_closed', True)
