clear memory? how?

Ben C spamspam at spam.eggs
Wed May 10 15:09:35 CEST 2006


On 2006-05-10, Grégoire Dooms <doomsAinfoDuclDacDbe at AisATandDisDOT.com> wrote:
> Ben C wrote:
>> On 2006-05-09, Ben C <spamspam at spam.eggs> wrote:
>>> def clearall():
>>>     all = [var for var in globals() if "__" not in (var[:2], var[-2:])]
>>>     for var in all:
>>>         del globals()[var]
>>>
>>> since I think magic things always start and end with __.
>> 
>> Oops, got that wrong anyway:
>> 
>> should be:
>> 
>>     all = [var for var in globals() if (var[:2], var[-2:]) != ("__", "__")]
>
> You can also add
> and var != "clearall"
>
>:-)

Good point :)

I've heard of "write once run anywhere", but this is "run once".



More information about the Python-list mailing list