Use cases for del
Peter Hansen
peter at engcorp.com
Thu Jul 7 18:11:09 EDT 2005
Duncan Booth wrote:
> Peter Hansen wrote:
>>Tom Anderson wrote:
>>>How about just getting rid of del?
>>
>>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".
>
> I generally find that unit tests force me to structure the code in a
> cleaner manner, e.g. to not use globals as much, but if you do need to
> delete a global you do it in exactly the same way as you delete anything:
> use the "del" statement:
Umm: huh? Tom suggested getting rid of del, I suggested it was required
for some cases in doing testing in the fact of globals (for cases where
they are the simplest approach), then you suggest that the correct
approach is to use "del".
Well, I agree (including your point on use of globals, which I attempted
to anticipate with my comment starting "sometimes"), but I don't really
see the point of your posting, Duncan... it appears redundant on all
counts.
-Peter
More information about the Python-list
mailing list