Hi,

my first, probably very naive, question to the list.... I want to
create an extension class with a method whose definition changes as a
function of some test
at the time of creation of the instance.
Something like:

cdef class Test:

    cdef int x, foo

    def __init__(self,foo):

        if foo>4:
            self.f = self.fn1
        else:
            self.f = self.fn2

    cdef fn1(self,x):
        return x

    cdef fn2(self,x):
        return 2 * x


Is this possible, and if yes, how should I declare f?

Thanks in advance for your help.

JF
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to