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

Dieter Maurer dieter at handshake.de
Thu Jun 29 13:25:30 EDT 2006


Greg Ewing <greg.ewing at canterbury.ac.nz> writes on Wed, 28 Jun 2006 11:56:55 +1200:
>...
> I have suggested that builtin functions should be
> given the same method-binding behaviour as interpreted
> functions. The idea wasn't rejected out of hand, but
> I don't think anything has been done about it yet.

You can use:

        def wrapAsMethod(to_be_wrapped)
          def wrapped(*args, **kw):
            return to_be_wrapper(*args, **kw)
          return wrapped

and then use in your class:

        class ...:
          ...
          myMethod = wrapAsMethod(builtin_function)


Such, this use case probably does not require a language change.


Dieter



More information about the Python-list mailing list