Calling member functions?

Oleg Broytmann phd at phd.pp.ru
Thu Dec 13 13:35:09 CET 2001


On Thu, Dec 13, 2001 at 12:22:17PM -0000, David Dawkins wrote:
> > >         self.m_method(self.m_object) ## naive attempt
> >
> >                ^^^^^^^^ You call a method with one argument, but the
> > Callback method does not accept any arguments.
> 
> but then how does Handler.Callback receive its own "self" value? In this

   m_method is not a method - it is *bound* method! It is h.Callback - an
object, that stores both h and Callback! So when you call it, Python gets
the self for Callback from the bound method; the self will by just h!
Understand?

                       vvvvvvvvvv - you initialized m_method with the bound method
> > > n = Notifier( h, h.Callback )

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            phd at phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.




More information about the Python-list mailing list