def autocurry(func, n=EMPTY, _spec=None, _args=(), _kwargs={}):
    """Creates a version of func returning its partial applications
       until sufficient arguments are passed."""
    spec = _spec or (get_spec(func) if n is EMPTY else Spec(n, set(), n, set(), False))

    @wraps(func)
    def autocurried(*a, **kw):
        args = _args + a
        kwargs = _kwargs.copy()
        kwargs.update(kw)

        if not spec.varkw and len(args) + len(kwargs) >= spec.max_n:
            return func(*args, **kwargs)
        elif len(args) + len(set(kwargs) & spec.names) >= spec.max_n:
            return func(*args, **kwargs)
        elif len(args) + len(set(kwargs) & spec.req_names) >= spec.req_n:
            try:
                return func(*args, **kwargs)
            except TypeError:
                return autocurry(func, _spec=spec, _args=args, _kwargs=kwargs)
        else:
            return autocurry(func, _spec=spec, _args=args, _kwargs=kwargs)

    return autocurried
Creates a version of func returning its partial applications
       until sufficient arguments are passed.
funcy/funcs.py