Ask for a filename to save as, and returned the opened file

def asksaveasfile(mode="w", **options):
    "Ask for a filename to save as, and returned the opened file"

    filename = asksaveasfilename(**options)
    if filename:
        return open(filename, mode)
    return None