def writeToFile(self, f, packed=True):
<EOL>schema = self.getSchema()<EOL>proto = schema.new_message()<EOL>self.write(proto)<EOL>if packed:<EOL><INDENT>proto.write_packed(f)<EOL><DEDENT>else:<EOL><INDENT>proto.write(f)<EOL><DEDENT>
Write serialized object to file.

:param f: output file
:param packed: If true, will pack contents.