Modifying builtin type behaviour

Jean-S?bastien Bolduc jseb at cs.mcgill.ca
Thu Feb 12 13:15:22 EST 2004


I'm afraid this is a silly question, to which I know the answer
already. But let me ask anyway...

In Python, is there a way to modify a builtin type's methods? for
instance, modifying int.__add__ to behave as multiplication, I would
obtain 2+5 == 10. I emphasize that I don't want to modify the Python
source, but change the types behaviour _from within Python_.

Help would be appreciated!



More information about the Python-list mailing list