RE: style question: how to delete all elements in a list

2006-03-06 Thread Delaney, Timothy (Tim)
gry@ll.mit.edu wrote: > To delete all the elements of a list, should one do: > >lst[:] = [] > or >del(lst[:]) del lst[:] Note that del is not a function - the parentheses are not needed, and in fact obscure the intent. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

style question: how to delete all elements in a list

2006-03-06 Thread gry
Just curious about people's sense of style: To delete all the elements of a list, should one do: lst[:] = [] or del(lst[:]) I seem to see the first form much more often in code, but the second one seems more clearly *deleting* elements, and less dangerously mistaken for the completely diff