##// END OF EJS Templates
Make hard reset the default with %reset.
Thomas Kluyver -
Show More
@@ -971,10 +971,10 b' Currently the magic system has the following functions:\\n"""'
971 ----------
971 ----------
972 -f : force reset without asking for confirmation.
972 -f : force reset without asking for confirmation.
973
973
974 -h : 'Hard' reset: gives you a new session and removes all
974 -s : 'Soft' reset: Only clears your namespace, leaving history intact.
975 references to objects from the current session. By default, we
975 References to objects may be kept. By default (without this option),
976 do a 'soft' reset, which only clears out your namespace, and
976 we do a 'hard' reset, giving you a new session and removing all
977 leaves input and output history around.
977 references to objects from the current session.
978
978
979 Examples
979 Examples
980 --------
980 --------
@@ -988,8 +988,8 b' Currently the magic system has the following functions:\\n"""'
988
988
989 In [9]: %reset -f
989 In [9]: %reset -f
990
990
991 In [10]: 'a' in _ip.user_ns
991 In [1]: 'a' in _ip.user_ns
992 Out[10]: False
992 Out[1]: False
993 """
993 """
994 opts, args = self.parse_options(parameter_s,'fh')
994 opts, args = self.parse_options(parameter_s,'fh')
995 if 'f' in opts:
995 if 'f' in opts:
@@ -1001,14 +1001,16 b' Currently the magic system has the following functions:\\n"""'
1001 print 'Nothing done.'
1001 print 'Nothing done.'
1002 return
1002 return
1003
1003
1004 if 'h' in opts: # Hard reset
1004 if 's' in opts: # Soft reset
1005 self.shell.reset(new_session = True)
1006
1007 else: # Soft reset
1008 user_ns = self.shell.user_ns
1005 user_ns = self.shell.user_ns
1009 for i in self.magic_who_ls():
1006 for i in self.magic_who_ls():
1010 del(user_ns[i])
1007 del(user_ns[i])
1011
1008
1009 else: # Hard reset
1010 self.shell.reset(new_session = True)
1011
1012
1013
1012 def magic_reset_selective(self, parameter_s=''):
1014 def magic_reset_selective(self, parameter_s=''):
1013 """Resets the namespace by removing names defined by the user.
1015 """Resets the namespace by removing names defined by the user.
1014
1016
@@ -392,7 +392,7 b' def test_reset_hard():'
392 _ip.run_cell("a")
392 _ip.run_cell("a")
393
393
394 nt.assert_equal(monitor, [])
394 nt.assert_equal(monitor, [])
395 _ip.magic_reset("-hf")
395 _ip.magic_reset("-f")
396 nt.assert_equal(monitor, [1])
396 nt.assert_equal(monitor, [1])
397
397
398 def doctest_who():
398 def doctest_who():
General Comments 0
You need to be logged in to leave comments. Login now