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 <whatever>[0] = 2, <whatever> is evaluated, and the result's __setitem__ is called. It is perfectly well-defined if the result is a list. Python doesn't care if it is a fresh list, or an already known one.
I guess it would be possible to change the grammar to disallow that, but do you really think it's worth it? And would you throw away also things such as [5,a][1][:]=[3]? ---------- nosy: +veky _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31263> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com