Hello,

I think i did not understand the handling character string. This is an  
example :

user.pyx :

cdef class User:
    def __init__(self, char* name):
        self.cname = name

    cpdef printName(self):
        print "My name is %s" % self.cname

user.pxd :

cdef class User:
    cdef readonly char* cname

    cpdef printName(self)

"compilation"  is going well but i have a problem with the use :

In [1]: from user import User

In [2]: u = User("Peyroux")

In [3]: u.
u.__class__         u.__delattr__       u.__doc__            
u.__getattribute__  u.__hash__          u.__init__           
u.__new__           u.__pyx_vtable__    u.__reduce__         
u.__reduce_ex__
u.__repr__          u.__setattr__       u.__str__            
u.cname             u.printName

In [3]: u.printName
Out[3]: <built-in method printName of user.User object at 0x52100>

In [4]: u.printName()
My name is _3

In [5]: u.cname
Out[5]: '_3'

I do not understand. My string is completely random, as if it was  
pointing in the wrong location of memory.
I missed step ?

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

Reply via email to