Question about idioms for clearing a list
Steven Watanabe
swatanabe at alias.com
Tue Jan 31 11:57:03 EST 2006
I know that the standard idioms for clearing a list are:
(1) mylist[:] = []
(2) del mylist[:]
I guess I'm not in the "slicing frame of mind", as someone put it, but
can someone explain what the difference is between these and:
(3) mylist = []
Why are (1) and (2) preferred? I think the first two are changing the
list in-place, but why is that better? Isn't the end result the same?
Thanks in advance.
--
Steven.
More information about the Python-list
mailing list