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='')
| 603 | |
| 604 | @line_magic |
| 605 | def reset_selective(self, parameter_s=''): |
| 606 | """Resets the namespace by removing names defined by the user. |
| 607 | |
| 608 | Input/Output history are left around in case you need them. |
| 609 | |
| 610 | %reset_selective [-f] regex |
| 611 | |
| 612 | No action is taken if regex is not included |
| 613 | |
| 614 | Options |
| 615 | -f : force reset without asking for confirmation. |
| 616 | |
| 617 | See Also |
| 618 | -------- |
| 619 | reset : invoked as ``%reset`` |
| 620 | |
| 621 | Examples |
| 622 | -------- |
| 623 | |
| 624 | We first fully reset the namespace so your output looks identical to |
| 625 | this example for pedagogical reasons; in practice you do not need a |
| 626 | full reset:: |
| 627 | |
| 628 | In [1]: %reset -f |
| 629 | |
| 630 | Now, with a clean namespace we can make a few variables and use |
| 631 | ``%reset_selective`` to only delete names that match our regexp:: |
| 632 | |
| 633 | In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8 |
| 634 | |
| 635 | In [3]: who_ls |
| 636 | Out[3]: ['a', 'b', 'b1m', 'b2m', 'b2s', 'b3m', 'b4m', 'c'] |
| 637 | |
| 638 | In [4]: %reset_selective -f b[2-3]m |
| 639 | |
| 640 | In [5]: who_ls |
| 641 | Out[5]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
| 642 | |
| 643 | In [6]: %reset_selective -f d |
| 644 | |
| 645 | In [7]: who_ls |
| 646 | Out[7]: ['a', 'b', 'b1m', 'b2s', 'b4m', 'c'] |
| 647 | |
| 648 | In [8]: %reset_selective -f c |
| 649 | |
| 650 | In [9]: who_ls |
| 651 | Out[9]: ['a', 'b', 'b1m', 'b2s', 'b4m'] |
| 652 | |
| 653 | In [10]: %reset_selective -f b |
| 654 | |
| 655 | In [11]: who_ls |
| 656 | Out[11]: ['a'] |
| 657 | |
| 658 | Notes |
| 659 | ----- |
| 660 | Calling this magic from clients that do not implement standard input, |
| 661 | such as the ipython notebook interface, will reset the namespace |
| 662 | without confirmation. |
nothing calls this directly
no test coverage detected