[Pyrex] type reading another type's attribute

Bryan Weingarten bryan.weingarten at pobox.com
Thu Oct 23 03:52:57 CEST 2003


i'm having trouble running code similar to this:

-- python --

f1 = Foo1()
f2 = Foo2(f1)

AttributeError: 'Foo1' object has no attribute 'ctx1'


-- pyrex --

cdef class Foo1:
    cdef context1 *ctx1

    def __init__(self):
        self.ctx1 = c_Foo1()

cdef class Foo2:
    cdef context2 *ctx2

    def __init__(self, foo1)::
        self.ctx2 = c_Foo2(foo1.ctx1)


it appears that class Foo2 is unable to see the context in Foo1.   would 
creating an def _get_context(self) method in class Foo1 be the right 
thing to do?

thanks,

bryan





More information about the Pyrex mailing list