|
Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in cl: msg#00047python.pyrex
Greg Ewing wrote: > Brian Blais wrote: >> I have found a very similar problem trying to replace a method using a >> function defined in pyrex. > > > What *should* work is to define the method inside a > class in Pyrex (plain class, not extension type) and > extract it out of the class's __dict__. That's because > Pyrex pre-wraps a function defined in a class in an > unbound method object before putting it in the class. > So I tried: #--------------------------------------------------------------------------------- #module_pyrex.pyx class update_funcs: def pyrex_update_within_class(self,val): print "pyrex module within class",val #--------------------------------------------------------------------------------- #(adding to test_replace_method.py) This.update4=module_pyrex.update_funcs.__dict__['pyrex_update_within_class'] t.update4('pyrex within class') # doesn't work #--------------------------------------------------------------------------------- and get: TypeError: unbound method pyrex_update_within_class() must be called with update_funcs instance as first argument (got str instance instead) did I do this wrong? thanks, bb -- ----------------- bblais@xxxxxxxxxx http://web.bryant.edu/~bblais -- http://mail.python.org/mailman/listinfo/python-list |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?): 00047, Greg Ewing |
|---|---|
| Next by Date: | Re: pyrex functions to replace a method (Re: replace a method in class: how?): 00047, Stefan Behnel |
| Previous by Thread: | Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?)i: 00047, Greg Ewing |
| Next by Thread: | Re: pyrex functions to replace a method (Re: replace a method in class: how?): 00047, Stefan Behnel |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |