[Pyrex] dealing with objects of 2 classes

Stefan Behnel stefan_ml at behnel.de
Mon Jun 15 08:23:35 CEST 2009


Bartosz SKOWRON wrote:
> On Mon, Jun 15, 2009 at 5:23 AM, Stefan Behnel<stefan_ml at behnel.de> wrote:
>
>>> 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'
>>
>> You have to declare the variables that you assign the objects to, as in
>>
>>        cdef b some_b
>>        some_b = b(a())
>>        print some_b.foo.some_struct_member
>
> but that b(a()) I would like to do from the Python interpreter, not in
> Pyrex.

Ah, ok. Then read the doc section on extension type attributes:

http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/extension_types.html#ExtTypeAttrs

Stefan




More information about the Pyrex mailing list