3 ms·
> They got rid of the super ugly [:] What do you mean by that? Can't we clear a list by doing: L[:] = [] (useful when L is defined in another scope, or w
by amelius 6y ago
> They got rid of the super ugly [:]
What do you mean by that? Can't we clear a list by doing:
L[:] = []
(useful when L is defined in another scope, or when you want to keep a reference to the same list object)
Unfortunately it's not possible to search for "[:]", so pointers appreciated
- ed25519FUUU 6y agoWait, why not just L.clear()?
- amelius 6y agoGood point. But you might still want e.g.: L[1:] = []
- ju-st 6y agoI just meant that you need the "[:]-operator" less often because of the new methods removeprefix, not that the thing is completely removed.