

t = ""

for operation, symbole in (("add", "+"), ("sub", "-"), ("mul", "*"), ("div", "/"), ("truediv", "/"), ("pow", "**"),  ("mod",  "%"), ("floordiv",  "//")):

    t += """
    def __%(operation)s__(self, y):
        return self.val %(symbole)s y

    def __r%(operation)s__(self, y):
        return y %(symbole)s self.val

    def __i%(operation)s__(self, y):
        self.val = self.val %(symbole)s y
        return self
""" %locals()

print t
