bundles / IPython 9.10.0 / IPython / core / magics / namespace / NamespaceMagics / reset_selective
function
IPython.core.magics.namespace:NamespaceMagics.reset_selective
Signature
def reset_selective ( self , parameter_s = '' ) Summary
Resets the namespace by removing names defined by the user.
Extended Summary
Input/Output history are left around in case you need them.
%reset_selective [-f] regex
No action is taken if regex is not included
Options
-fforce reset without asking for confirmation.
Notes
Calling this magic from clients that do not implement standard input, such as the ipython notebook interface, will reset the namespace without confirmation.
Examples
We first fully reset the namespace so your output looks identical to this example for pedagogical reasons; in practice you do not need a full reset:: In [1]: %reset -f Now, with a clean namespace we can make a few variables and use ``%reset_selective`` to only delete names that match our regexp:: In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 In [3]: who_ls Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] In [4]: %reset_selective -f b[2-3]m In [5]: who_ls Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] In [6]: %reset_selective -f d In [7]: who_ls Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] In [8]: %reset_selective -f c In [9]: who_ls Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] In [10]: %reset_selective -f b In [11]: who_ls Out[11]: ['a']See also
- reset
invoked as
%reset
Aliases
-
IPython.core.magics.NamespaceMagics.reset_selective