object-oriented programming the built-in exec(function dynamically executes the code passed to it from the object it is given in this case we have given it stringbut it is also possible to pass some other kinds of objects by defaultthe code is executed in the context of the enclosing scopein this case within the definition of the fuzzybool classso the def statements that are executed create fuzzybool methods which is what we want the code is executed just oncewhen the fuzzyboolalt module is imported here is the code that is generated for the first tuple ("__neg__""-")def __neg__(self)raise typeerror("bad operand type for unary -'{self}'format(self=self __class__ __name__)we have made the exception and error message match those that python uses for its own types the code for handling binary methods and -ary functions (such as pow()follows similar pattern but with different error message for completenesshere is the code we have usedfor nameoperator in (("__xor__""^")("__ixor__""^=")("__add__""+")("__iadd__""+=")("__radd__""+")("__sub__""-")("__isub__""-=")("__rsub__""-")("__mul__""*")("__imul__""*=")("__rmul__""*")("__pow__""**")("__ipow__""**=")("__rpow__""**")("__floordiv__""//")("__ifloordiv__""//=")("__rfloordiv__""//")("__truediv__""/")("__itruediv__""/=")("__rtruediv__""/")("__divmod__""divmod()")("__rdivmod__""divmod()")("__mod__""%")("__imod__""%=")("__rmod__""%")("__lshift__""<<")("__ilshift__""<<=")("__rlshift__"">")("__irshift__"">>=")("__rrshift__"">>"))message ("unsupported operand type(sfor { }"'{{self}}'{{join}{{args}}format(operator)exec("def { }(self*args):\ntypes [\"'\arg __class__ __name__ \"'\"for arg in args]\nraise typeerror(\"{ }\format("self=self __class__ __name__"join=(\and\if len(args= else \",\"),"args=\"\join(types)))format(namemessage)this code is slightly more complicated than before because for binary operators we must output messages where the two types are listed as type and type but for three or more types we must list them as type type type to mimic dynamic programming