A 'Python like' language

Greg Ewing (using news.cis.dfn.de) ieyf4fu02 at sneakemail.com
Tue Mar 30 07:15:15 CEST 2004


Mark Hahn wrote:
>>     f = someobj.somemeth
>>     someotherobj.g = f
>>     someotherobj.g()
>>
>>   What does the "self" object inside the call to somemeth
>>   refer to then -- someobj, or someotherobj?
> 
> It refers to someotherobj.

You have a problem, then. This means passing functions around
is fragile. If you store one in an attribute of an object, it
mutates into something different when you get it back out
again.

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list