In a pure functional style:
flip = lambda f: lambda *a: f(*reversed(a)) def divide(a, b): return a / b print flip(divide)(3.0, 1.0)
A somewhat interesting example:
unreplace = lambda s: flip(s.replace) replacements = ['abc', 'XYZ'] a = 'abc123' b = a.replace(*replacements) print b print unreplace(b)(*replacements)
source share