[Pyrex] dealing with objects of 2 classes

Bartosz SKOWRON getxsick at gmail.com
Mon Jun 15 05:29:37 CEST 2009


Hello,

I have a new problem which I cannot find a solution.

Here is a very simple example:

cdef class a:
    cdef foobar_t *foo
    def __init__(self):
           self.foo = extern_func1()

cdef class b:
   cdef foobar_t *_foobar
   def __init__(self, obja):
           self._foobar = obja.foo

cdef class c:
   def __init__(self, obja):
           self._foobar = obja


when i create new object of class b, `b(a())`  i get:
AttributeError: 'a' object has no attribute 'foo'

when i create new object of class c, `c(a())`  i get:
AttributeError: 'c' object has no attribute '_foobar'

In first case, I don't understand what's happen. Do I need extern
somehow 'foo' attribute?

In second, propably I need to declare _foobar first (cdef foobar_t
*_foobar) and prepare some manual conversion. Am I right?

Or this case should be done completely different?

thanks for words,
bart.



More information about the Pyrex mailing list