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. > It would be nice if your confusion could have been avoided by reading the reference manual, but unfortunately the current syntax definition doesn't seem to even acknowledge the possibility of multiple assignments such as the one under discussion!
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden Recent Ramblings http://holdenweb.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list