Use cases for del

Dieter Maurer dieter at handshake.de
Thu Jul 7 14:19:14 EDT 2005


Daniel Dittmar <daniel.dittmar at sap.corp> writes on Wed, 06 Jul 2005 16:12:46 +0200:
> Peter Hansen wrote:
> > Arguing the case for del: how would I, in doing automated testing,
> > ensure that I've returned everything to a "clean" starting point in
> > all cases if I can't delete variables?  Sometimes a global is the
> > simplest way to do something... how do I delete a global if not with
> > "del"?
> 
> 
> globals ().__delitem__ (varname)
> 
> except that the method would probably be called delete.

You now have a uniform way to remove an object from a namespace.

Why would you want to give each namespace its own method to
remove objects from it?

Can you imagine how much code you would break (would your proposal
to remove "del" got accepted)?


Dieter



More information about the Python-list mailing list