list.clear() missing?!?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Wed Apr 12 19:23:08 EDT 2006


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).

As far as I know, it is impossible -- or at least very hard -- for an
object to know which namesspaces it is in, so it can reassign one name but
not the others. Even if such a thing was possible, I think it is an
absolutely bad idea.



-- 
Steven.




More information about the Python-list mailing list