|
pyrex functions to replace a method (Re: replace a method in class: how?): msg#00045python.pyrex
Thanks for all who replied to this question about replacing a method. I feel a little sheepish for not having caught that I have to replace it in the class, not the instance, but I have found a very similar problem trying to replace a method using a function defined in pyrex. I post all of the code below, but there are several files. The main code is: import module_py # import a function from a python module import module_pyrex # import a function from a pyrex extension module class This(object): def update1(self,val): print val def update2(self,val): print "2",val def update3(self,val): print "3",val def local_update(obj,val): print "local",val This.update1=local_update # replace the method from a local function This.update2=module_py.python_update # replace the method from a python module This.update3=module_pyrex.pyrex_update # replace the method from a pyrex module t=This() t.update1('local') # works fine t.update2('python') # works fine t.update3('pyrex') # gives a typeerror function takes exactly 2 arguments (1 given) #--------------------------------------------------------------------------------- #module_py.py def python_update(self,val): print "python module",val #--------------------------------------------------------------------------------- #module_pyrex.pyx def pyrex_update(self,val): print "pyrex module",val #--------------------------------------------------------------------------------- any ideas why the pyrex function fails? thanks, bb -- ----------------- bblais@xxxxxxxxxx http://web.bryant.edu/~bblais |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Pyrex exception type checking broken under Python 2.5 (and earlier): 00045, Greg Ewing |
|---|---|
| Next by Date: | Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?): 00045, Greg Ewing |
| Previous by Thread: | Pyrex exception type checking broken under Python 2.5 (and earlier)i: 00045, Stefan Behnel |
| Next by Thread: | Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?): 00045, Greg Ewing |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |