On Sun, Nov 22, 2009 at 2:30 AM, Shashwat Anand <anand.shash...@gmail.com>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. > Please note this is only the same because you happen to be using an immutable type! using the 'on separate lines' version is preferable because you won't accidentally do something like this: >>> a = b = [] >>> a.append('foo') >>> a ['foo'] >>> b ['foo'] >>> if you forget your type is mutable.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor