Use cases for del

Jp Calderone exarkun at divmod.com
Wed Jul 6 10:00:02 EDT 2005


On Wed, 06 Jul 2005 09:45:56 -0400, Peter Hansen <peter at engcorp.com> wrote:
>Tom Anderson wrote:
>> How about just getting rid of del? Removal from collections could be
>> done with a method call, and i'm not convinced that deleting variables
>> is something we really need to be able to do (most other languages
>> manage without it).
>
>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"?
>

Unless you are actually relying on the global name not being defined, "someGlobal = None" would seem to do just fine.

Relying on the global name not being defined seems like an edge case.

Jp



More information about the Python-list mailing list