Hello,

I must be missing something minor but I just can't figure it out.  I  
am trying to replace a method in a class with a cdef function defined  
in cython, but keep getting the error:

TypeError: function takes exactly 2 arguments (1 given)


I include an example to reproduce the issue, with the .py file and  
the .pyx file, below.  Any help would be great!


thanks,

                        Brian Blais

testit.py
=========
class mything(object):

     def __init__(self,N):
         self.N=N

     def doit(self,x):

         val=0
         for i in range(self.N,x):
             val+=i

         return val

try:
     import c_testit
     mything.doit=c_testit.doit
     print "Using cython version"
except ImportError:
     pass

if __name__=="__main__":

     a=mything(10)
     print a.doit(50)


c_testit.pyx
============
cpdef doit(object self,int x):

     cdef int i
     cdef int N=self.N
     cdef int val

     val=0
     for i from N<=i<x:
         val+=i

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

Reply via email to