A small inconsistency in syntax?
William Tanksley
wtanksle at dolphin.openprojects.net
Fri Oct 26 17:14:16 EDT 2001
On 26 Oct 2001 23:05:23 +0200, Chris Liechti wrote:
>this; [1,2][1]=23
>should raise an "SyntaxError: can't assign to literal", but does not.
Why? There are many types of literals; some of them are mutable and some
are immutable. You can't assign to an immutable literal (try your example
with a tuple), but there's no reason to stop you from assigning to (or
modifying) a mutable literal.
This statement, in this case, has the effect of converting the [1,2] list
to [1,23], and then discarding it.
>Chris <cliechti at gmx.net>
--
-William "Billy" Tanksley
More information about the Python-list
mailing list