Show More
@@ -187,7 +187,27 b' class NonBlockingIPShell(object):' | |||||
187 | def bypassMagic(self, arg): |
|
187 | def bypassMagic(self, arg): | |
188 | print '%this magic is currently disabled.' |
|
188 | print '%this magic is currently disabled.' | |
189 | ip.expose_magic('cpaste', bypassMagic) |
|
189 | ip.expose_magic('cpaste', bypassMagic) | |
190 |
|
190 | |||
|
191 | def resetMagic(self, arg): | |||
|
192 | """Resets the namespace by removing all names defined by the user. | |||
|
193 | ||||
|
194 | Input/Output history are left around in case you need them.""" | |||
|
195 | ||||
|
196 | ans = True ##todo find away to ask the user... | |||
|
197 | ##seems hard to do it cleanly... | |||
|
198 | if not ans: | |||
|
199 | print 'Nothing done.' | |||
|
200 | return | |||
|
201 | user_ns = self.shell.user_ns | |||
|
202 | for i in self.magic_who_ls(): | |||
|
203 | del(user_ns[i]) | |||
|
204 | ||||
|
205 | # Also flush the private list of module references kept for script | |||
|
206 | # execution protection | |||
|
207 | self.shell._user_main_modules[:] = [] | |||
|
208 | ||||
|
209 | ip.expose_magic('reset', resetMagic) | |||
|
210 | ||||
191 | sys.excepthook = excepthook |
|
211 | sys.excepthook = excepthook | |
192 |
|
212 | |||
193 | #----------------------- Thread management section ---------------------- |
|
213 | #----------------------- Thread management section ---------------------- |
General Comments 0
You need to be logged in to leave comments.
Login now