On 4 Sep 2006 09:39:32 -0700, Sandra-24 <[EMAIL PROTECTED]> wrote: > How can you prevent self from being passed to a function stored as a > member variable? > > class Foo(object): > def __init__(self, callback): > self.func = callback > > f =Foo(lambda x: x) > f.func(1) # TypeError, func expects 1 argument, recieved 2
Do you really get that error? I got the following in my python shell: .>>> class Foo(object): .... def __init__(self, callback): .... self.func = callback .... .>>> f = Foo(lambda x: x) .>>> f.func(1) 1 -- http://mail.python.org/mailman/listinfo/python-list