Python 3000 idea: reversing the order of chained assignments

Mark T nospam at
Thu Mar 22 05:09:52 CET 2007

"Marcin Ciura" <marcin.ciura at> wrote in message 
news:ets9hc$74f$1 at
> Given
>   class Node(object):
>       pass
>   node = Node()
>   nextnode = Node()
> I tried to refactor the following piece of code
> = nextnode
>   node = nextnode

You have an error above.  The first node's "next" points to nextnode, then 
node is reassigned to point to nextnode, losing the original node!
The refactoring below is doing the same thing.  It is, however, evaluating 
right-to-left as you want.  nextnode is place in and placed in 
node, also losing the original value of node.

-Mark T.

> as
>   node = = 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?
>   Marcin

More information about the Python-list mailing list