a short-cut command for globals().clear() ??

Terry Reedy tjreedy at udel.edu
Tue Sep 23 10:25:43 CEST 2008


MRAB wrote:
>
> How about something like this:
> 
> def clear_workspace():
>     keep_set = set(['__builtins__', '__doc__', '__name__',
> 'clear_workspace'])

For 2.6/3.0, add __package__ to the list to be kept.

>     for x in globals().keys():
>         if x not in keep_set:
>             del globals()[x]
> --
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list