Re: [Tutor] multiple assignment on one line

2009-11-22 Thread bob gailer
Shashwat Anand wrote: Ok, this is silly but i want to know is multiple assignment is possible in one line using "+=, -=, *= etc" operators on python 2.6.4 Read the manual: 6.3.1 Augmented assignment statements "target augop expression_list An augmented assignment evaluates the target (which, u

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Lie Ryan
Alan Gauld wrote: "Lie Ryan" wrote I was a bit surprised this doesn't work though: a, b += k, k What would you expect? I expect a, b += c, d to be a += c; b += d just like a, b = c, d to be a = c; b = d Remember that a,b = c,d is just tuple assignment without using parens (and pare

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Shashwat Anand
Ohh, I never thought it this way. Thanks for enlightening. On Sun, Nov 22, 2009 at 9:52 PM, Alan Gauld wrote: > > "Lie Ryan" wrote > > > I was a bit surprised this doesn't work though: > >> >> a, b += k, k >> >> > What would you expect? > Remember that > > a,b = c,d > > is just tuple assignment

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Alan Gauld
"Lie Ryan" wrote I was a bit surprised this doesn't work though: a, b += k, k What would you expect? Remember that a,b = c,d is just tuple assignment without using parens (and parens are not part of the tuple definition) So using tuples a,b += k,k would unwrap as a,b = (a,b) + (k,k

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Luke Paireepinart
On Sun, Nov 22, 2009 at 2:30 AM, Shashwat Anand wrote: > Ok, this is silly but i want to know is multiple assignment is possible in > one line using "+=, -=, *= etc" operators on python 2.6.4 > > like a,b = 0,1 which is equal to > a = 0 > b = 1 > on seperate lines. > similarly a = b = 0 which is e

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Lie Ryan
Alan Gauld wrote: "Shashwat Anand" wrote Can we pack these two statements in one line ? a += k b += k of course a,b +=k will not work but is there any such option available? Not that I'm aware. And when I tried it just to see what happens it killed IDLE completely - Window disappeared

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Lie Ryan
Shashwat Anand wrote: Ok, this is silly but i want to know is multiple assignment is possible in one line using "+=, -=, *= etc" operators on python 2.6.4 like a,b = 0,1 which is equal to a = 0 b = 1 on seperate lines. similarly a = b = 0 which is equal to a = 0 b = 0 on seperate lines. Can we

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Shashwat Anand
thanks Alan, i was just curious, thats it. And yeah, simplest is best :) On Sun, Nov 22, 2009 at 2:38 PM, Alan Gauld wrote: > > "Shashwat Anand" wrote > > > Can we pack these two statements in one line ? >> a += k >> b += k >> > > of course a,b +=k will not work but is there any such option av

Re: [Tutor] multiple assignment on one line

2009-11-22 Thread Alan Gauld
"Shashwat Anand" wrote Can we pack these two statements in one line ? a += k b += k of course a,b +=k will not work but is there any such option available? Not that I'm aware. And when I tried it just to see what happens it killed IDLE completely - Window disappeared and everything! Y

[Tutor] multiple assignment on one line

2009-11-22 Thread Shashwat Anand
Ok, this is silly but i want to know is multiple assignment is possible in one line using "+=, -=, *= etc" operators on python 2.6.4 like a,b = 0,1 which is equal to a = 0 b = 1 on seperate lines. similarly a = b = 0 which is equal to a = 0 b = 0 on seperate lines. Can we pack these two statement