[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-24 Thread Vedran Čačić
Vedran Čačić added the comment: I'm really curious about why exactly do you think that behavior is _incorrect_? Unfortunate, maybe. Similar to a mutable default argument. But it is completely consistent with Python semantics. -- ___ Python tracker

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread R. David Murray
R. David Murray added the comment: Sometimes it does, sometimes we make the change in a feature release, often after a deprecation period. But in this case there is doubt that the behavior is incorrect in the first place. This discussion should move to the python-ideas mailing list. I'm

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread Isaac Elliott
Isaac Elliott added the comment: Does backward compatibility take priority over correct behavior? What process is followed when fixing a bug causes a breaking change? -- ___ Python tracker

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread R. David Murray
R. David Murray added the comment: If you would disallow "a = [0]; [5, a][1][:] = [3]", then your proposal will not be accepted, for backward compatibility reasons if nothing else. -- versions: +Python 3.7 -Python 3.5, Python 3.6 ___ Python tracker

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread Isaac Elliott
Isaac Elliott added the comment: Yes I would disallow a script such as `a = [0]; [5, a][1][:] = [3]` (note: your example of just `[5, a][1][:] = [3]` does not run, so I assumed it must be used in a situation like this) Evaluating the target of an assignment is unnecessary, we can syntactically

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread R. David Murray
R. David Murray added the comment: I'm don't have a lot of experience with parsers, but I suspect that we consider the cost of making the grammar more complex to be more significant than the benefit we'd get from catching these at compile time. And as Vedran says, defining what can be caught

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-23 Thread Vedran Čačić
Vedran Čačić added the comment: There is no such thing as "sliced literal" per se. And [1,2,3] is in fact _not_ a literal (it's a _list display_, at least it was the last time I learned Python's vocabulary.) [1,2,3][0] is an expression, which is a slice. When you write [0] = 2, is evaluated,

[issue31263] Assigning to subscript/slice of literal is permitted

2017-08-22 Thread Isaac Elliott
New submission from Isaac Elliott: In Python 3.5 and 3.6 (at least), the language reference presents a grammar that disallows assignment to literals. For example, `(a for 1 in [1,2,3])` is a syntax error, as is `(1, a) = (2, 3)`. However the grammar doesn't prevent assignment to subscripted