Mark T wrote: > > "Alex Martelli" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >> John Nagle <[EMAIL PROTECTED]> wrote: >> >>> Marcin Ciura wrote: >>> >>> > Neither would I. I must have expressed myself not clearly enough. >>> > Currently >>> > x = y = z >>> > is roughly equivalent to >>> > x = z >>> > y = z >>> > I propose to change it to >>> > y = z >>> > x = z >>> >>> Actually, it is equivalent to >>> >>> y = z >>> x = y >> >> >> Not really: >> >>>>> class chatty(object): >> >> ... def __init__(self): self.__dict__['__hide'] = {} >> ... def __setattr__(self, name, value): >> ... print 'sa', name, value >> ... self.__dict__['__hide'][name] = value >> ... def __getattr__(self, name): >> ... print 'ga', name >> ... return self.__dict__['__hide'].get(name) >> ... >> >>>>> c = chatty() >>>>> x = c.zop = 23 >> >> sa zop 23 >> >>>>> >> >> As you can see, there is no read-access to c.zop, which plays the role >> of y there. >> >> >> Alex > > > This is interesting: > >>>> class Test(object): > > ... def __getattribute__(self,n): > ... print 'reading',n > ... return object.__getattribute__(self,n) > ... def __setattr__(self,n,v): > ... print 'writing',n,v > ... return object.__setattr__(self,n,v) > ... > >>>> x=Test() >>>> x.a=1; x.b=2; x.c=3 > > writing a 1 > writing b 2 > writing c 3 > >>>> x.a=x.b=x.c > > reading c > writing a 3 > writing b 3 > >>>> > > I wouldn't have expected "a" to be assigned first in a right-to-left > parsing order. The result is the same in any case. > > -Mark T.
That's fascinating. Is that a documented feature of the language, or a quirk of the CPython interpreter? John Nagle -- http://mail.python.org/mailman/listinfo/python-list