why no ++?

Markus Schaber markus at schabi.de
Tue Aug 14 13:54:57 CEST 2001


Hi,

Michael Abbott <michael at rcp.co.uk> schrub:
 
> Oops!  Very true.  I should have rewritten it as

>      e = 'wow'
>      b,c,d = 'wow'
>      a = 'wow'

This still isn't exactly true.

Imagine, that the expression on the right side has side effects, than 
you shoud only evaluate it one time. 

And with the get/set operators that seem to emerge, access to instance 
variables also can have side effects, that means the order in which you 
assign is incorrect, as - at least according to chapter 6.3 of th 1.5.2 
reference manual - the assignment order is strictly left to right.

In those cases, one would have to write

  tmp = "wow"
  a = tmp
  b,c,d = tmp
  e = tmp
  del tmp

to acheive the same behaviour as in
  a = b,c,d = e = "wow"

(as long as I didn't miss anything)

> Hmm.  The argument about obfuscation versus repetition comes more
> clearly
> into focus.  I still think multiple assignment is a bad thing...

Then just don't use it :-)

I think it sometimes is a good thing to have, but you have to know 
about the exact semantics.


markus

-- 
1) Customers cause problems.
2) Marketing is trying to create more customers.
Therefore:
3) Marketing is evil.  (Grand Edwards in comp.lang.python)



More information about the Python-list mailing list