def write(self, data):
_complain_ifclosed(self.closed)<EOL>if self.__encoding:<EOL><INDENT>self.f.write(data.encode(self.__encoding, self.__errors))<EOL>return len(data)<EOL><DEDENT>else:<EOL><INDENT>return self.f.write(data)<EOL><DEDENT>
Write ``data`` to the file.

:type data: bytes
:param data: the data to be written to the file
:rtype: int
:return: the number of bytes written