[Pyrex] [newbie] 3 errors need help

dunk dunk at dunkfordyce.co.uk
Tue Dec 20 11:32:44 CET 2005


On Tuesday 20 December 2005 08:54, Test Drive wrote:
> cdef class MyClass:
>    cdef SessionCTX  *___Session___
>    def
> __init__(self,server="127.0.0.1",port=8080,key="abcdefgh0123456789"):
> self.Server=server
>       self.Port=port
>       self.Key=key
>       self.Keylen=len(self.Key)
>       self.res=None
>    def connect(self):
>       self.res=Connect(&self.__Session__,self.Server,self.Port,<unsigned
> char *>self.Key,self.Keylen)
>       return self.res

unless you havent pasted something... you never define a type for 
MyClass.Server, so when doing Connect(&self.__Session__, self.Server...
self.Server is as far as we know a python variable. Then looking at your 
delcaration for the Connect function the second argument is a char *. This is 
the cause of your problems. I think if you declare MyClass.Server and 
possibly others like the following it should work:

cdef class MyClass:
  cdef char *Server
  def __init__(....):
	# your code

beware that declaring vars like this is _not_ like in python. I dont know 
how( or if indeed its possible ) to create class variables instead of 
instance variables in pyrex.

dunk



More information about the Pyrex mailing list