[PyQt] Re: SIP - patched methods with lazy lookups
Matt Newell
newellm at blur.com
Tue Apr 22 19:35:05 BST 2008
On Tuesday 22 April 2008 10:47:12 Kevin Watters wrote:
> > old_init = MyClass.__init__ def new_init(self, foo, bar=5, meep=13):
> > old_init(self, foo, bar, meep) MyClass.__init__ = new_init
> >
> > assert MyClass.__init__ is new_init # FAIL
>
> Oops. That should be
>
> old_init = MyClass.__init__
> def new_init(self, foo, bar=5, meep=13):
> old_init(self, foo, bar, meep)
>
> MyClass.__init__ = new_init
>
> assert MyClass.__init__ is new_init # FAIL
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
We are doing something similar. It works if you create a new class that
inherits from MyClass, then replace MyClass with the new one.
class MyClassOverride(MyClass):
def __init__(self, food, bar=5, meep=13):
MyClass.__init__(self,foo,bar,meep)
MyClass = MyClassOverride
Matt
More information about the PyQt
mailing list