class_docstr: Serializable base class establishing
  :meth:`~nupic.serializable.Serializable.read` and
  :meth:`~nupic.serializable.Serializable.write` abstract methods,
  :meth:`.readFromFile` and :meth:`.writeToFile` concrete methods to support
  serialization with Cap'n Proto.
docstr: Write serialized object to file.
  
  :param f: output file
  :param packed: If true, will pack contents.
docstr_tok: ["Write","serialized","object","to","file",".",":","param","f",":","output","file",":","param","packed",":","If","true",",","will","pack","contents","."]
code: def writeToFile(self, f, packed=True):
      """
      Write serialized object to file.
  
      :param f: output file
      :param packed: If true, will pack contents.
      """
      # Get capnproto schema from instance
      schema = self.getSchema()
  
      # Construct new message, otherwise refered to as `proto`
      proto = schema.new_message()
  
      # Populate message w/ `write()` instance method
      self.write(proto)
  
      # Finally, write to file
      if packed:
          proto.write_packed(f)
      else:
          proto.write(f)
  
file_path: nupic-legacy/src/nupic/serializable.py
imports: from abc import ABCMeta, abstractmethod
label_desc: Use image node_id 5 for calling the Serializable obj's underlying member method code with example usage: obj.writeToFile(f, packed) without return types