[Cython] wrapping c code, classmethod question

Uwe Schmitt uschmitt at mineway.de
Mon Oct 6 18:03:44 CEST 2008


Hi,

I'm trying to wrap an existing C entension as follows:

    cdef struct A:
        double * values
        int n


    cdef class Test:
        cdef A a

        @classmethod
        def buildFromData(cls, filename):

            cdef A a # = foofoo(filename)

            obj = cls()
            obj.a = a
            return obj

Running Cython the "obj.a=a" results in """Cannot convert 'A' to Python 
object""".

So: how can I instantiate extension classes from classmethods ?

Greetings, Uwe


-- 
Dr. rer. nat. Uwe Schmitt
F&E Mathematik
 
mineway GmbH
Science Park 2
D-66123 Saarbrücken
 
Telefon: +49 (0)681 8390 5334
Telefax: +49 (0)681 830 4376
 
uschmitt at mineway.de
www.mineway.de
 
Geschäftsführung: Dr.-Ing. Mathias Bauer
Amtsgericht Saarbrücken HRB 12339


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/cython-dev/attachments/20081006/e1c0ff8e/attachment.htm 


More information about the Cython-dev mailing list