How to dynamically override __setitem__? (no subclass)
问题 I'm not able to override some builtin functions, such as '__setitem__', in Python2.7 (although the same occurs in previous versions I tested) Although I know this is easy to do via subclassing, this is not what I want here, I need to be able to dynamically override these methods. Apparently, when my class is a subclass of ' object ', the overridden method always ends up calling the original one, but when my class is not an ' object ', it works: >>> def new_implementation(k, v): ... print 'New