In article <[EMAIL PROTECTED]>, Steven D'Aprano <[EMAIL PROTECTED]> wrote: >On Wed, 12 Apr 2006 15:36:47 -0700, Alan Morgan wrote: > >> Serious question: Should it work more like "s=[]" or more like >> "s[:]=[]". I'm assuming the latter, but the fact that there is >> a difference is an argument for not hiding this operation behind >> some syntactic sugar. > >Er, I don't see how it can possibly work like s = []. That merely >reassigns a new empty list to the name s, it doesn't touch the existing >list (which may or may not be garbage collected soon/immediately >afterwards).
Right. I was wondering what would happen in this case: s=[1,2,3] t=s s.clear() t # [] or [1,2,3]?? If you know your basic python it is "obvious" what would happen if you do s=[] or s[:]=[] instead of s.clear() and I guess it is equally "obvious" which one s.clear() must mimic. I'm still not used to dealing with mutable lists. Alan -- Defendit numerus -- http://mail.python.org/mailman/listinfo/python-list