Re: [Quantlib-users] Observable Python objects
Posted by Luigi Ballabio-2 on Nov 10, 2003; 8:44am
URL: http://quantlib.414.s1.nabble.com/Observable-Python-objects-tp10448p10451.html
On 2003.11.10 17:23, Andre Louw wrote:
> I have been trying to use (abuse?) the observer swig interface to get
> my Python objects to be 'Observable', not so simple! In fact, no
> luck!
Andre',
I'd go for containment instead of inheritance, as the latter
does not happily cross the Python/C boundaries. Defining a Python
class like:
import QuantLib
class MyObserver:
def __init__(self):
self.obs = QuantLib.Observer(self.update)
def update(self):
print "Override me!"
def registerWith(self,o):
self.obs.registerWith(o)
and inheriting from MyObserver should work, but beware---I didn't test
it. As a matter of fact, I didn't even tried to run it through the
Python interpreter...
Later,
Luigi