def METHOD_NAME(self, filename=None, ignore_discard=False, ignore_expires=False):
    if filename is None:
        if self.filename is not None: filename = self.filename
        else: raise ValueError(MISSING_FILENAME_TEXT)
    f = open(filename, "w")
    try:
        # There really isn't an LWP Cookies 2.0 format, but this indicates
        # that there is extra information in here (domain_dot and
        # port_spec) while still being compatible with libwww-perl, I hope.
        f.write("#LWP-Cookies-2.0\n")
        f.write(self.as_lwp_str(ignore_discard, ignore_expires))
    finally:
        f.close()