What *instance* called me & proxy methods

Carlos Alberto Reis Ribeiro cribeiro at mail.inet.com.br
Wed Mar 28 19:04:56 EST 2001


At 14:42 28/03/01 -0800, Emile van Sebille wrote:
>It seems to me that what you're trying to do is discover the container of an
>instance.  Whether the instance is wrapped in a class or held in a list,
>when the instance's methods are invoked, self is self and not the container.
>If you take a look at pep 232
>http://python.sourceforge.net/peps/pep-0232.html you may find that, if
>instance method attribute setting were allowed, this could be what you're
>looking for.

Thanks for the pointer. Note that I have two related problems, and this PEP 
may solve both of them.

1) I want to have a way to hide the im_* pointers from the code. The 
intention is to hide the implementation details of the object that is being 
'proxied'.

2) I want to set some special property to indicate who's the 'owner'. The 
problem is that instances may be referenced in several places. So my idea 
is to create a proxy, that is owned by the container, but points to the 
same instance method.


>Perhaps you can take this PEP to the next step if it's what you're after

Maybe I'll give it a try - not now, but in a few weeks.


Carlos Ribeiro






More information about the Python-list mailing list