From b20f75fc0827abd485ede1793381942f360c414a 2009-01-26 22:19:37 From: laurent dufrechou Date: 2009-01-26 22:19:37 Subject: [PATCH] Added a workaround for %reset magic as it is using raw_input via ask_yes_no. --- diff --git a/IPython/gui/wx/ipshell_nonblocking.py b/IPython/gui/wx/ipshell_nonblocking.py index e09151e..6af9f20 100644 --- a/IPython/gui/wx/ipshell_nonblocking.py +++ b/IPython/gui/wx/ipshell_nonblocking.py @@ -187,7 +187,27 @@ class NonBlockingIPShell(object): def bypassMagic(self, arg): print '%this magic is currently disabled.' ip.expose_magic('cpaste', bypassMagic) - + + def resetMagic(self, arg): + """Resets the namespace by removing all names defined by the user. + + Input/Output history are left around in case you need them.""" + + ans = True ##todo find away to ask the user... + ##seems hard to do it cleanly... + if not ans: + print 'Nothing done.' + return + user_ns = self.shell.user_ns + for i in self.magic_who_ls(): + del(user_ns[i]) + + # Also flush the private list of module references kept for script + # execution protection + self.shell._user_main_modules[:] = [] + + ip.expose_magic('reset', resetMagic) + sys.excepthook = excepthook #----------------------- Thread management section ----------------------