Why '==' ??
JCM
joshway_without_spam at myway.com
Tue Mar 30 09:35:49 EST 2004
Vrai Stacey <spam.trap.vrai.stacey at spam.trap.kbcfp.com> wrote:
> JCM wrote:
>> a = b = c
>> a = b == c
> I had no idea you could do that! I was under the impression that
> assignment didn't return a value in Python, hence it being impossible to
> use one as a conditional.
Assignment actually doesn't return a value; the multple-assignment
statement assigns a value to the left-hand-sides in a left-to-right
order. Eg:
>>> a = 0
>>> lst = [10, 20, 30, 40]
>>> a = lst[a] = 3
>>> lst
[10, 20, 30, 3]
(You might have expected [3, 20, 30, 40])
More information about the Python-list
mailing list