def replace(a, b, x):
    """
    return x, unless x == a then return b

    l2 = map(partial(replace, a, b), l1)

    l2 will be the same as l1, except that anything
    equal to a will have been replaced by b.

    map(partial(replace, 1, 2), [1, 2, 3]) == [2, 2, 3]
    """
    return (b if x == a else x)