Curious assignment behaviour
Dale Strickland-Clark
dale at riverhall.NOSPAMco.uk
Mon Oct 8 07:55:28 EDT 2001
I observe that the folowing works as some might expect:
x = y = 5
Assigns 5 to both x and y.
However the expression:
y = 5
does not yeild 5
>>> print y = 5
Traceback ( File "<interactive input>", line 1
print y = 5
^
SyntaxError: invalid syntax
>>>
So this is obviously a gludge in assignment.
I'd be much happier if assignment yeilds the value assigned, as it
does in C (I believe). It could then be used universaly.
Also, where is this curious behaviour documented? 6.3 of the Language
Ref makes no reference to it. (Go on. Prove me wrong!)
Thanks.
--
Dale Strickland-Clark
Riverhall Systems Ltd
More information about the Python-list
mailing list