MCPcopy Create free account
hub / github.com/ipython/ipython / reset

Method reset

IPython/core/magics/namespace.py:479–602  ·  view source on GitHub ↗

Resets the namespace by removing all names defined by the user, if called without arguments, or by removing some types of objects, such as everything currently in IPython's In[] and Out[] containers (see the parameters for details). Parameters ----------

(self, parameter_s='')

Source from the content-addressed store, hash-verified

477
478 @line_magic
479 def reset(self, parameter_s=''):
480 """Resets the namespace by removing all names defined by the user, if
481 called without arguments, or by removing some types of objects, such
482 as everything currently in IPython's In[] and Out[] containers (see
483 the parameters for details).
484
485 Parameters
486 ----------
487 -f : force reset without asking for confirmation.
488
489 -s : 'Soft' reset: Only clears your namespace, leaving history intact.
490 References to objects may be kept. By default (without this option),
491 we do a 'hard' reset, giving you a new session and removing all
492 references to objects from the current session.
493
494 in : reset input history
495
496 out : reset output history
497
498 dhist : reset directory history
499
500 array : reset only variables that are NumPy arrays
501
502 See Also
503 --------
504 reset_selective : invoked as ``%reset_selective``
505
506 Examples
507 --------
508 ::
509
510 In [6]: a = 1
511
512 In [7]: a
513 Out[7]: 1
514
515 In [8]: 'a' in get_ipython().user_ns
516 Out[8]: True
517
518 In [9]: %reset -f
519
520 In [1]: 'a' in get_ipython().user_ns
521 Out[1]: False
522
523 In [2]: %reset -f in
524 Flushing input history
525
526 In [3]: %reset -f dhist in
527 Flushing directory history
528 Flushing input history
529
530 Notes
531 -----
532 Calling this magic from clients that do not implement standard input,
533 such as the ipython notebook interface, will reset the namespace
534 without confirmation.
535 """
536 opts, args = self.parse_options(parameter_s,'sf', mode='list')

Callers

nothing calls this directly

Calls 6

who_lsMethod · 0.95
parse_optionsMethod · 0.80
ask_yes_noMethod · 0.80
popMethod · 0.80
flushMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected