def write_text(self, data, encoding=None, errors=None):
        """
        Open the file in text mode, write to it, and close the file.
        """
        if not isinstance(data, six.text_type):
            raise TypeError(
                'data must be %s, not %s' %
                (six.text_type.__class__.__name__, data.__class__.__name__))
        with self.open(mode='w', encoding=encoding, errors=errors) as f:
            return f.write(data)
def write_text ( self , data , encoding = None , errors = None ) : if not isinstance ( data , six . text_type ) : raise TypeError ( 'data must be %s, not %s' % ( six . text_type . __class__ . __name__ , data . __class__ . __name__ ) ) with self . open ( mode = 'w' , encoding = encoding , errors = errors ) as f : return f . write ( data )
Open the file in text mode, write to it, and close the file.