logo       

Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in cl: msg#00052

python.pyrex

Subject: Re: [Pyrex] pyrex functions to replace a method (Re: replace a method in class: how?)

Brian Blais wrote:

> TypeError: unbound method pyrex_update_within_class() must be called
> with update_funcs instance as first argument (got str instance instead)

Hm. Okay, so that doesn't work either.

But I just tried the following, and it seems
to work:

import new

class C(str):
pass

C.ord = new.instancemethod(ord, None, C)

c = C("a")

print c.ord()

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise