why no ++?
Michael Abbott
michael at rcp.co.uk
Tue Aug 14 09:27:54 EDT 2001
Markus Schaber <markus at schabi.de> wrote in
news:1709172.gFLt9SDvcz at lunix.schabi.de:
> 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 should 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.
Oh dearie me. Well, I think this does support my case about obfuscation,
but I agree that your writing out is much more long winded.
>
> 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)
LOL. I expect we're there now: except of course, you have to add the
proviso that tmp is a new name not already in use
>
>> 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.
Bah! I confess defeat (mostly).
Well, I didn't know the detailed semantics, so it's been quite useful to
learn how this actually works...
More information about the Python-list
mailing list