fredrik at pythonware.com
Tue Jan 8 16:45:01 CET 2008
Giampaolo Rodola' wrote:
> To flush a list it is better doing "del mylist[:]" or "mylist = "?
> Is there a preferred way? If yes, why?
The latter creates a new list object, the former modifies an existing
list in place.
The latter is shorter, reads better, and is probably a bit faster in
The former should be used when it's important to clear a specific list
object (e.g. if there are multiple references to the list).
More information about the Python-list