Show More
@@ -319,6 +319,9 b' class DisplayHook(Configurable):' | |||||
319 | except: pass |
|
319 | except: pass | |
320 | self.shell.user_ns['_oh'].clear() |
|
320 | self.shell.user_ns['_oh'].clear() | |
321 |
|
321 | |||
|
322 | # Release our own references to objects: | |||
|
323 | self._, self.__, self.___ = '', '', '' | |||
|
324 | ||||
322 | if '_' not in __builtin__.__dict__: |
|
325 | if '_' not in __builtin__.__dict__: | |
323 | self.shell.user_ns.update({'_':None,'__':None, '___':None}) |
|
326 | self.shell.user_ns.update({'_':None,'__':None, '___':None}) | |
324 | import gc |
|
327 | import gc |
@@ -1045,6 +1045,9 b' class InteractiveShell(Configurable, Magic):' | |||||
1045 | # Clear histories |
|
1045 | # Clear histories | |
1046 | self.history_manager.reset(new_session) |
|
1046 | self.history_manager.reset(new_session) | |
1047 |
|
1047 | |||
|
1048 | # Flush cached output items | |||
|
1049 | self.displayhook.flush() | |||
|
1050 | ||||
1048 | # Reset counter used to index all histories |
|
1051 | # Reset counter used to index all histories | |
1049 | self.execution_count = 0 |
|
1052 | self.execution_count = 0 | |
1050 |
|
1053 | |||
@@ -1069,6 +1072,10 b' class InteractiveShell(Configurable, Magic):' | |||||
1069 | self.alias_manager.clear_aliases() |
|
1072 | self.alias_manager.clear_aliases() | |
1070 | self.alias_manager.init_aliases() |
|
1073 | self.alias_manager.init_aliases() | |
1071 |
|
1074 | |||
|
1075 | # Flush the private list of module references kept for script | |||
|
1076 | # execution protection | |||
|
1077 | self.clear_main_mod_cache() | |||
|
1078 | ||||
1072 | def reset_selective(self, regex=None): |
|
1079 | def reset_selective(self, regex=None): | |
1073 | """Clear selective variables from internal namespaces based on a |
|
1080 | """Clear selective variables from internal namespaces based on a | |
1074 | specified regular expression. |
|
1081 | specified regular expression. |
@@ -967,12 +967,15 b' Currently the magic system has the following functions:\\n"""' | |||||
967 | def magic_reset(self, parameter_s=''): |
|
967 | def magic_reset(self, parameter_s=''): | |
968 | """Resets the namespace by removing all names defined by the user. |
|
968 | """Resets the namespace by removing all names defined by the user. | |
969 |
|
969 | |||
970 | Input/Output history are left around in case you need them. |
|
|||
971 |
|
||||
972 | Parameters |
|
970 | Parameters | |
973 | ---------- |
|
971 | ---------- | |
974 | -f : force reset without asking for confirmation. |
|
972 | -f : force reset without asking for confirmation. | |
975 |
|
973 | |||
|
974 | -h : 'Hard' reset: gives you a new session and removes all | |||
|
975 | references to objects from the current session. By default, we | |||
|
976 | do a 'soft' reset, which only clears out your namespace, and | |||
|
977 | leaves input and output history around. | |||
|
978 | ||||
976 | Examples |
|
979 | Examples | |
977 | -------- |
|
980 | -------- | |
978 | In [6]: a = 1 |
|
981 | In [6]: a = 1 | |
@@ -988,8 +991,8 b' Currently the magic system has the following functions:\\n"""' | |||||
988 | In [10]: 'a' in _ip.user_ns |
|
991 | In [10]: 'a' in _ip.user_ns | |
989 | Out[10]: False |
|
992 | Out[10]: False | |
990 | """ |
|
993 | """ | |
991 |
|
994 | opts, args = self.parse_options(parameter_s,'fh') | ||
992 | if parameter_s == '-f': |
|
995 | if 'f' in opts: | |
993 | ans = True |
|
996 | ans = True | |
994 | else: |
|
997 | else: | |
995 | ans = self.shell.ask_yes_no( |
|
998 | ans = self.shell.ask_yes_no( | |
@@ -997,14 +1000,15 b' Currently the magic system has the following functions:\\n"""' | |||||
997 | if not ans: |
|
1000 | if not ans: | |
998 | print 'Nothing done.' |
|
1001 | print 'Nothing done.' | |
999 | return |
|
1002 | return | |
|
1003 | ||||
|
1004 | if 'h' in opts: # Hard reset | |||
|
1005 | self.shell.reset(new_session = True) | |||
|
1006 | ||||
|
1007 | else: # Soft reset | |||
1000 | user_ns = self.shell.user_ns |
|
1008 | user_ns = self.shell.user_ns | |
1001 | for i in self.magic_who_ls(): |
|
1009 | for i in self.magic_who_ls(): | |
1002 | del(user_ns[i]) |
|
1010 | del(user_ns[i]) | |
1003 |
|
1011 | |||
1004 | # Also flush the private list of module references kept for script |
|
|||
1005 | # execution protection |
|
|||
1006 | self.shell.clear_main_mod_cache() |
|
|||
1007 |
|
||||
1008 | def magic_reset_selective(self, parameter_s=''): |
|
1012 | def magic_reset_selective(self, parameter_s=''): | |
1009 | """Resets the namespace by removing names defined by the user. |
|
1013 | """Resets the namespace by removing names defined by the user. | |
1010 |
|
1014 |
General Comments 0
You need to be logged in to leave comments.
Login now