Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Duncan Booth
Steve Holden <[EMAIL PROTECTED]> wrote: >> As a matter of interest do PyLint or PyChecker check for this situation >> (chained assignment where the target of an assignment is also a >> subexpression of a later assignment)? >> > Where's the published syntax for chained assignment? http://docs.p

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Terry Reedy
"Steve Holden" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Terry Reedy wrote: | > The assignment order is specified in the language reference. | | Where? I'm looking at | | http://docs.python.org/ref/assignment.html | | right now. The first line of the syntax grammar is: assi

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Erik Johnson
Actually, after studying this a bit more: http://docs.python.org/ref/assignment.html I guess that makes sense. Sorry if I muddied the water for anyone else in my boat: n1 = n1.next = n2 The first thing that happens is the expression list is evaluated which is the thing on the far right, n2. That

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Erik Johnson
"Virgil Dupras" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > class Node: > > > ... pass > > > ... > > node = Node() > > nextnode = Node() > > backup_node = node > > node = node.next = nextnode > > node.next is node > > > True > > hasattr(ba

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread John Nagle
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 equiv

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Ziga Seilnacht
John Nagle wrote: > > That's fascinating. Is that a documented feature of the language, > or a quirk of the CPython interpreter? > Its a documented feature of the language. From the Reference Manual: "An assignment statement evaluates the expression list (remember that this can be a single ex

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Duncan Booth
Steve Holden <[EMAIL PROTECTED]> wrote: > In other words, > > assignment_stmt ::= (target_list "=") expression_list | > (target_list "=") assignment_stmt > > and > > assignment_stmt ::= (target_list "=") assignment_stmt | >

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Steve Holden
Duncan Booth wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: > >>> As a matter of interest do PyLint or PyChecker check for this situation >>> (chained assignment where the target of an assignment is also a >>> subexpression of a later assignment)? >>> >> Where's the published syntax for chaine

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Steve Holden
Duncan Booth wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: > >> Help me out here. It looks as though the real syntax should >> be something like >> >> assignment_stmt ::= (target_list "=")+ expression_list | >> (target_list "=")+ assignment_stmt >

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Duncan Booth
Steve Holden <[EMAIL PROTECTED]> wrote: > Help me out here. It looks as though the real syntax should > be something like > > assignment_stmt ::= (target_list "=")+ expression_list | > (target_list "=")+ assignment_stmt That is precisely the point. I

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Steve Holden
Duncan Booth wrote: > "Virgil Dupras" <[EMAIL PROTECTED]> wrote: > >> I think I see what Marcin means. The 'node' is changed too fast in the >> chain, and next is assigned to 'nextnode' instead of being assigned to >> node. > > I can see why Marcin was confused. Many other languages assignment is

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Duncan Booth
"Virgil Dupras" <[EMAIL PROTECTED]> wrote: > I think I see what Marcin means. The 'node' is changed too fast in the > chain, and next is assigned to 'nextnode' instead of being assigned to > node. I can see why Marcin was confused. Many other languages assignment is an expression, so a=b=c is si

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Steve Holden
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 >

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-22 Thread Steve Holden
Terry Reedy wrote: > "Mark T" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > | This is interesting: > | > | >>> class Test(object): > | ... def __getattribute__(self,n): > | ... print 'reading',n > | ... return object.__getattribute__(self,n) > | ... def __setattr__(se

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Terry Reedy
"Mark T" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | 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

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Mark T
"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

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Mark T
"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 n

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Steve Holden
Virgil Dupras wrote: > On Mar 21, 9:24 pm, Steve Holden <[EMAIL PROTECTED]> wrote: >> Marcin Ciura wrote: >>> Steven D'Aprano wrote: >>> 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). >>> Neither would I. I must have express

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Virgil Dupras
On Mar 21, 10:05 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Virgil Dupras wrote: > > On Mar 21, 9:24 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > >> Marcin Ciura wrote: > >>> Steven D'Aprano wrote: > >>> x, y, z = 1, 2, 3 > >>> x = y = z > >>> x, y, z > (3, 3, 3) > I certa

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Alex Martelli
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 >

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Virgil Dupras
On Mar 21, 9:24 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Marcin Ciura wrote: > > Steven D'Aprano wrote: > > 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). > > > Neither would I. I must have expressed myself not clearl

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Steve Holden
Marcin Ciura wrote: > Steven D'Aprano wrote: > 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). > > Neither would I. I must have expressed myself not clearly enough. > Currently > x = y = z > is roughly equivalent to > x = z > y =

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread John Nagle
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 > Python performs chained assignments

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Terry Reedy
"Marcin Ciura" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Neither would I. I must have expressed myself not clearly enough. | Currently | x = y = z | is roughly equivalent to | x = z | y = z except that z is only evaluated once. | I propose to change it to | y = z | x = z Un

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Marcin Ciura
Steven D'Aprano wrote: 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). 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

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Steven D'Aprano
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

Re: Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Ben Finney
Marcin Ciura <[EMAIL PROTECTED]> writes: >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. What makes you think so? >>> a = "foo" >>> b = "bar" >>> c =

Python 3000 idea: reversing the order of chained assignments

2007-03-21 Thread Marcin Ciura
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 langu