Message passing between python objects

Peter Otten __peter__ at web.de
Mon Mar 19 09:27:11 EDT 2012


J. Mwebaze wrote:

> I am trying to learn about the interaction between python objects. One
> thing i have often read is that objects interact by sending messages to
> other objects to invoke corresponding methods. I am specifically
> interested in tracing these messages and also probably log the messages
> for further scrutiny. I would like to build a provenance kind of system.

The term "message" occurs in various contexts in computing. You have 
probably encountered these

http://en.wikipedia.org/wiki/Smalltalk#Messages
http://en.wikipedia.org/wiki/Message_loop_in_Microsoft_Windows

and are mixing the two meanings. However, methods in Python are ordinary 
functions that know about "their" instance. Given a = A()

a.method(1, 2)

and

A.method(a, 1, 2)

are equivalent, no animals are hurt and no messages passed.




More information about the Python-list mailing list