how to know who calls a method

Alex Garel alex.garel at free.fr
Fri Apr 9 17:54:02 EDT 2004


Hello,
Maybe it's a strange question.
I heard that salltalk use messages that are sent from one object to another.
It seems in other OO languages, method call is quite an implementation 
of that. The only thing is, the receiver (instance which method is being 
called) can't retrieve reference of the sender. Is it possible in Python 
? Is there a standard way or a workaround.
I think about using frame stack (in module inspect) but it only gives me 
the name of the function from which I was called, not a reference to the 
object.
Why am I asking for such a feature ?
It is because I would like an object to be aware of another object 
reading it so it can signal future change in its value to the last. I 
can use a getter which precise who is the reader but my attempt was to 
be able to use a normal getter (x=y)  in a Phytonic fashion !



More information about the Python-list mailing list