code: def save(self, filename):
          '''save waypoints to a file'''
          f = open(filename, mode='w')
          f.write("QGC WPL 110\n")
          for w in self.wpoints:
              if getattr(w, 'comment', None):
                  f.write("# %s\n" % w.comment)
              f.write("%u\t%u\t%u\t%u\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%u\n" % (
                  w.seq, w.current, w.frame, w.command,
                  w.param1, w.param2, w.param3, w.param4,
                  w.x, w.y, w.z, w.autocontinue))
          f.close(f save(self, filename):
          '''save waypoints to a file'''
          f = open(filename, mode='w')
          f.write("QGC WPL 110\n")
          for w in self.wpoints:
              if getattr(w, 'comment', None):
                  f.write("# %s\n" % w.comment)
              f.write("%u\t%u\t%u\t%u\t%f\t%f\t%f\t%f\t%f\t%f\t%f\t%u\n" % (
                  w.seq, w.current, w.frame, w.command,
                  w.param1, w.param2, w.param3, w.param4,
                  w.x, w.y, w.z, w.autocontinue))
          f.close()
docs: save waypoints to a file