code: def save(self, filename, format=None, **kwargs):
          
          if format is None:
              # try to derive protocol from file extension
              format = format_from_extension(filename)
          with file(filename, 'wb') as fp:
              self.save_to_file_object(fp, format, **kwargs)
docs: Save the object to file given by filename.