3 ms·
yeah, i figured out what it did by playing in the repl, but i still can't find it documented anywhere.
by zem 16y ago
yeah, i figured out what it did by playing in the repl, but i still can't find it documented anywhere.
- StavrosK 16y agoI tried a bit in the REPL and couldn't replicate it completely, but I didn't try hard. It seems to only work because of the CPython internals, so it seems to be implementation-specific and undocumented.
- cool-RR 16y agoNot true, it's part of Python's syntax. Here it is in Pypy: Python 2.5.2 (79560, Nov 26 2010, 14:57:55) [PyPy 1.4.0] on win32 >>> a = [1, 2 ,3] >>> for a[:] in [[6, 7, 8]]: ... pass >>> print(a) [6, 7, 8]
- StavrosK 16y agoSo what does it do? Run the expression first and assign to whatever's there? It seems that it would only work to assign to a slice, as anything else would be overwritten, but why?