On Wed, 21 Mar 2007 22:53:55 +0100, Marcin Ciura wrote: > Given > class Node(object): > pass > > node = Node() > nextnode = Node() > > I tried to refactor the following piece of code > node.next = nextnode > node = nextnode > > as > node = node.next = nextnode > > only to discover that Python performs chained assignments > backwards compared to other languages, i.e. left-to-right > instead of right-to-left. From the user's perspective, > I can't think of any reasonable argument for keeping it > this way in Python 3000. What is your opinion?
Well, this user's perspective is that if I read from left to right, which I do, then I expect most operations to also go from left to right, and not from right to left. Assignment is one exception to that. If I say "x = y = z" then I expect that afterwards x and y and z should all have the same value. >>> x, y, z = 1, 2, 3 >>> x, y, z (1, 2, 3) >>> x = y = z >>> x, y, z (3, 3, 3) I certainly wouldn't expect to get (2, 3, 3). -- Steven. -- http://mail.python.org/mailman/listinfo/python-list