A small inconsistency in syntax?
Chris Liechti
cliechti at gmx.net
Fri Oct 26 17:29:10 EDT 2001
More information about the Python-list mailing list
Fri Oct 26 17:29:10 EDT 2001
- Previous message (by thread): A small inconsistency in syntax?
- Next message (by thread): A small inconsistency in syntax?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
wtanksle at dolphin.openprojects.net (William Tanksley) wrote in news:slrn9tjkh7.kq0.wtanksle at dolphin.openprojects.net: > 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. ok writing it explicit makes it logic... >>> l=[3,2] >>> l [3, 2] >>> l[1]=23 >>> l [3, 23] i thought that when you write [3,2][1] = 23 that the LHS is evaluated to 2 and 2=23 does obviously raise an exception. when you look at the explicit example, i see how it works, but i would think that, when i look at the compact example, the complete left hand side would be evaluated before assignment (like it is on the right side). -- Chris <cliechti at gmx.net>
- Previous message (by thread): A small inconsistency in syntax?
- Next message (by thread): A small inconsistency in syntax?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list