"Marcin Ciura" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Given
>   class Node(object):
>       pass
>
>   node = Node()
>   nextnode = Node()
>
> I tried to refactor the following piece of code
>   node.next = 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 node.next and placed in 
node, also losing the original value of node.

-Mark T.

>
> 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?
>   Marcin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to