weak reference to bound method

Ole Streicher ole-usenet-spam at gmx.net
Fri Oct 2 13:33:37 CEST 2009


Hi Peter,

Peter Otten <__peter__ at web.de> writes:
> class Method(object):
>     def __init__(self, obj, func=None):
>         if func is None:
>             func = obj.im_func
>             obj = obj.im_self

This requires that func is a bound method. What I want is to have a
universal class that "always" works: with unbound functions, with
bound function, with lambda expressions, with locally defined functions,
...

For a user of my class, there is no visible reason, why some of them
shall work, while others dont.

Viele Grüße

Ole



More information about the Python-list mailing list