why no ++?

Bernd Nawothnig Bernd.Nawothnig at t-online.de
Sun Aug 19 14:47:10 EDT 2001


On 19 Aug 2001 18:28:23 GMT, Bernd Nawothnig <Bernd.Nawothnig at t-online.de>
wrote:

>>  Sure -- Python guarantees left-to-right behavior of this statement.
>>  First wower is called, then y.a is assigned, then b,c,d, then x.e, in this
>>  order.  But of course it wouldn't be wise to rely on this!-)

>  Hmm, without having true symbol-expressions (lvals speaken in C-ish) it
>  makes no difference which of the different symbols is bound physically first
>  to a value because there can't be any side effect.

Sorry, this isn't true, of course:

v=[0]*10
i=5
v[i]=i=7
results in:

[0, 0, 0, 0, 0, 7, 0, 0, 0, 0]

And this makes a difference. In case of right to left evaluation we would have

[0, 0, 0, 0, 0, 0, 0, 7, 0, 0]

as the result




Bernd



More information about the Python-list mailing list