On Thu, Mar 24, 2016, at 11:18, BartC wrote: > On 24/03/2016 15:03, Jon Ribbens wrote: > > No it isn't, it's replacing the elements in-place, > > Replace them with what, if not an entirely new list built from > '[0]*len(L)'?
Well, the *contents* of such a list, obviously. But the original list's contents are replaced, meaning that e.g. all other references to the list remain valid etc. > (And which would briefly require twice the memory occupied > by the old list, if I'm not mistaken.) Sure, *briefly*. And if you really care about that, you can do L[:] = (0 for x in L); or itertools.repeat(0, len(L)). -- https://mail.python.org/mailman/listinfo/python-list