weak reference to bound method
Peter Otten
__peter__ at web.de
Fri Oct 2 07:47:22 EDT 2009
Ole Streicher wrote:
> 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,
That's left as an exercise to the reader ;)
More information about the Python-list
mailing list