def create_closure_and_function(*args):
    func = None

def create_function_closure():
    return func
closure = create_function_closure.__closure__
func = types.FunctionType(*(args[:-1] + [closure]))
return func
How can I serialise a recursive function?