[Python-3000] removing functions from string module (original) (raw)

Christian Heimes lists at cheimes.de
Wed Apr 18 03:49:16 CEST 2007


Josiah Carlson schrieb:

I would generally agree with you, except that when monkey patching instances... self.method = new.instancemethod(other.method.imfunc, self, self.class)

.... is a bit more understandable than... self.metbod = type(other.method)(other.method.imfunc, self, self.class) .... at least in the examples that I've seen. Never mind that new is documented in the standard library documentation, but the types are not.

I strongly emphasize on "a bit more". One needs a lot of inside knowledge about internal representation to rebind a method to another instance. The following idea is much easier to understand:

self.method = boundmethod(self, method_or_function)

Christian



More information about the Python-3000 mailing list