Tim Peters wrote: >>>>x = [1] >>>>x.extend(-y for y in x) > A simpler way: >>> x = [1, -1] >>> x.extend(iter(x)) Curiously, this didn't "work" before 2.4 either: >>> x = [1] >>> x.extend(iter(x)) >>> x [1, 1] The iterator did see the new elements after the extend call but not during it: >>> x = [1] >>> i = iter(x) >>> x.extend(x) >>> list(i) [1, 1] >>> x = [1] >>> i = iter(x) >>> x.extend([list(i)]) >>> x [1, [1]] The reason is that in 2.3 `listextend()` passed the right argument through `PySequence_Fast` which copied it before beggining to extend the list. It's much better now. I mean it! Bugs should be predictable. Infinite loop should never terminate silently. Unless explicitly terminated.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4