On Jan 8, 7:34 am, "Giampaolo Rodola'" <[EMAIL PROTECTED]> wrote: > I was wondering... > To flush a list it is better doing "del mylist[:]" or "mylist = []"? > Is there a preferred way? If yes, why?
To empty an existing list without replacing it, the choices are "del mylist[:]" and "mylist[:] = []". Of the two, I prefer the former because it reads more explicity (delete all of the items from the list"). In terms of performance, they are basically the same. To replace a list, "mylist = []" is the way to go. This is an affirmative statement that you are creating a new list. Raymond -- http://mail.python.org/mailman/listinfo/python-list