MCPcopy Index your code
hub / github.com/ipython/ipython / reset_selective

Method reset_selective

IPython/core/magics/namespace.py:621–705  ·  view source on GitHub ↗

Resets the namespace by removing names defined by the user. 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 -f : force reset without asking for confirmation.

(self, parameter_s='')

Source from the content-addressed store, hash-verified

619
620 @line_magic
621 def reset_selective(self, parameter_s=''):
622 """Resets the namespace by removing names defined by the user.
623
624 Input/Output history are left around in case you need them.
625
626 %reset_selective [-f] regex
627
628 No action is taken if regex is not included
629
630 Options
631 -f : force reset without asking for confirmation.
632
633 See Also
634 --------
635 reset : invoked as ``%reset``
636
637 Examples
638 --------
639 We first fully reset the namespace so your output looks identical to
640 this example for pedagogical reasons; in practice you do not need a
641 full reset::
642
643 In [1]: %reset -f
644
645 Now, with a clean namespace we can make a few variables and use
646 ``%reset_selective`` to only delete names that match our regexp::
647
648 In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8
649
650 In [3]: who_ls
651 Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c']
652
653 In [4]: %reset_selective -f b[2-3]m
654
655 In [5]: who_ls
656 Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']
657
658 In [6]: %reset_selective -f d
659
660 In [7]: who_ls
661 Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c']
662
663 In [8]: %reset_selective -f c
664
665 In [9]: who_ls
666 Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m']
667
668 In [10]: %reset_selective -f b
669
670 In [11]: who_ls
671 Out[11]: ['a']
672
673 Notes
674 -----
675 Calling this magic from clients that do not implement standard input,
676 such as the ipython notebook interface, will reset the namespace
677 without confirmation.
678 """

Callers

nothing calls this directly

Calls 4

who_lsMethod · 0.95
parse_optionsMethod · 0.80
ask_yes_noMethod · 0.80
searchMethod · 0.45

Tested by

no test coverage detected