A 'Python like' language

Mark Hahn mark at prothon.org
Tue Mar 30 08:46:42 CEST 2004


I need a better understanding of this.  You are suggesting the self stay
with a function like a closure of sorts?

In my mind, anytime you say obj.func(), func is called on obj, no ifs ands
or buts.  How could it be otherwise?  When would you want it otherwise?

You say fragile.  What breaks?


"Greg Ewing (using news.cis.dfn.de)" <ieyf4fu02 at sneakemail.com> wrote in
message news:c4avp5$2g4b0b$1 at ID-169208.news.uni-berlin.de...
> 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