[Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?)
Brian Blais
bblais at bryant.edu
Wed Jun 28 11:02:39 UTC 2006
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 at bryant.edu
http://web.bryant.edu/~bblais
More information about the Pyrex
mailing list