list.clear() missing?!?

Mel Wilson mwilson-to at sympatico.ca
Thu Apr 13 08:12:58 EDT 2006


Alan Morgan wrote:
> In article <1144870852.886477.238570 at u72g2000cwu.googlegroups.com>,
> Raymond Hettinger <python at rcn.com> wrote:
>>* s.clear() is more obvious in intent
> 
> 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. 


It has to work more like s[:]=[]

It's not easy for an object method to bind a whole different 
object to the first object's name.  Generally only 
statements can affect namespaces (hence the uses of del that
everyone remembers.)

	Mel.



More information about the Python-list mailing list