##// END OF EJS Templates
- Cleanup [1786], which went in with unfinished stuff by accident....
- Cleanup [1786], which went in with unfinished stuff by accident. - Revert [1785] and replace it by installing our own quitter in place of the builtin (for all py versions). This obviates the need for [1785] and gives a cleaner exit. - Fix ipdb to work with python 2.5, and update ipdb color schemes with %colors. - irunner improvements, mostly for use as a doctest runner.

File last commit:

r284:9c6bbd29
r368:ede41cba
Show More
clearcmd.py
46 lines | 1.3 KiB | text/x-python | PythonLexer
# -*- coding: utf-8 -*-
""" IPython extension: add %clear magic """
import IPython.ipapi
import gc
ip = IPython.ipapi.get()
def clear_f(self,arg):
""" Clear various data (e.g. stored history data)
%clear out - clear output history
%clear in - clear input history
"""
api = self.getapi()
for target in arg.split():
if target == 'out':
print "Flushing output cache (%d entries)" % len(api.user_ns['_oh'])
self.outputcache.flush()
elif target == 'in':
print "Flushing input history"
from IPython import iplib
del self.input_hist[:]
del self.input_hist_raw[:]
for n in range(1,self.outputcache.prompt_count + 1):
key = '_i'+`n`
try:
del self.user_ns[key]
except: pass
elif target == 'array':
try:
pylab=ip.IP.pylab
for x in self.user_ns.keys():
if isinstance(self.user_ns[x],pylab.arraytype):
del self.user_ns[x]
except AttributeError:
print "Clear array only available in -pylab mode"
gc.collect()
ip.expose_magic("clear",clear_f)