def bind(foo, *boundargs, **boundkw):
    """ Allows binding some of the function's args, using placeholders _1, _2,
    etc for the args that are NOT bound (or curried, if you like)
    ========= FOOD FOR DOCTEST ===========
    >>> def foo(a, b, c, d = None, e = None): return (a, b, c, d, e)
    >>> foo(1, 2, 3, e = 'Nooo!')
    (1, 2, 3, None, 'Nooo!')
    >>> foo1 = bind(foo, _2, 2, _1, e = 'Nee!')
    >>> foo1(1, 3)
    (3, 2, 1, None, 'Nee!')
    Test overriding the bound args with the calltime args
    >>> foo1(1, 3, e = 'Overritten')
    (3, 2, 1, None, 'Overritten')
    """
    def with_bound_args(*a, **kw):
        args = []
        for arg in boundargs:
            if isinstance(arg, placeholder):
                args.append(a[arg.pos])
            else:
                args.append(arg)
        #>>> (Update) Peter Harris (PEP 309) mentioned
        #>>> that it makes much more sense to override
        #>>> the bound keyword args with call-time args;
        #>>> hence we have to make a copy of the bound
        #>>> dict and update it, rather than updatinng the 
        #>>> call-time keyword arg dictionary. I agree
        #>>> with the point, although there is an alternative
        #>>> of treating it as an error. The more lenient 
        #>>> way seems more Pythonic.
        kwdict = boundargs.copy()
        kwdict.update(kw)
        return foo(*args, **kwdict)
    return with_bound_args
 Allows binding some of the function's args, using placeholders _1, _2,
    etc for the args that are NOT bound (or curried, if you like)
    ========= FOOD FOR DOCTEST ===========
    >>> def foo(a, b, c, d = None, e = None): return (a, b, c, d, e)
    >>> foo(1, 2, 3, e = 'Nooo!')
    (1, 2, 3, None, 'Nooo!')
    >>> foo1 = bind(foo, _2, 2, _1, e = 'Nee!')
    >>> foo1(1, 3)
    (3, 2, 1, None, 'Nee!')
    Test overriding the bound args with the calltime args
    >>> foo1(1, 3, e = 'Overritten')
    (3, 2, 1, None, 'Overritten')
    
recipes/Python/440557_BoostBind_PythvariatiCurry_technique_partial/recipe-440557.py