def new_closure(vals):
    """
    Build a new closure
    """
    args = ','.join('x%i' % i for i in range(len(vals)))
    f = eval("lambda %s:lambda:(%s)" % (args, args))
    if sys.version_info[0] >= 3:
        return f(*vals).__closure__
    return f(*vals).func_closure
def new_closure ( vals ) : args = ',' . join ( 'x%i' % i for i in range ( len ( vals ) ) ) f = eval ( "lambda %s:lambda:(%s)" % ( args , args ) ) if sys . version_info [ 0 ] >= 3 : return f ( * vals ) . __closure__ return f ( * vals ) . func_closure
Build a new closure