[Python-3000] removing functions from string module
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.im_func,
> self,
> self.__class__)
>
> .... is a bit more understandable than...
> self.metbod = type(other.method)(other.method.im_func,
> 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