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

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Jun 29 01:52:25 CEST 2006


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



More information about the Python-list mailing list