diff --git a/IPython/core/magics/osm.py b/IPython/core/magics/osm.py index e7a0567..6c9da55 100644 --- a/IPython/core/magics/osm.py +++ b/IPython/core/magics/osm.py @@ -31,7 +31,6 @@ from IPython.core.magic import ( Magics, compress_dhist, magics_class, line_magic, cell_magic, line_cell_magic ) from IPython.testing.skipdoctest import skip_doctest -from IPython.utils.io import nlprint from IPython.utils.openpy import source_to_unicode from IPython.utils.path import unquote_filename from IPython.utils.process import abbrev_cwd @@ -403,7 +402,7 @@ class OSMagics(Magics): %dhist -> print full history\\ %dhist n -> print last n entries only\\ - %dhist n1 n2 -> print entries between n1 and n2 (n1 not included)\\ + %dhist n1 n2 -> print entries between n1 and n2 (n2 not included)\\ This history is automatically maintained by the %cd command, and always available as the global list variable _dh. You can use %cd - @@ -425,14 +424,15 @@ class OSMagics(Magics): ini,fin = max(len(dh)-(args[0]),0),len(dh) elif len(args) == 2: ini,fin = args + fin = min(fin, len(dh)) else: self.arg_err(self.dhist) return else: ini,fin = 0,len(dh) - nlprint(dh, - header = 'Directory history (kept in _dh)', - start=ini,stop=fin) + print 'Directory history (kept in _dh)' + for i in range(ini, fin): + print "%d: %s" % (i, dh[i]) @skip_doctest @line_magic diff --git a/IPython/utils/io.py b/IPython/utils/io.py index ec00a29..90aa59f 100644 --- a/IPython/utils/io.py +++ b/IPython/utils/io.py @@ -242,44 +242,6 @@ def ask_yes_no(prompt,default=None): return answers[ans] -class NLprinter: - """Print an arbitrarily nested list, indicating index numbers. - - An instance of this class called nlprint is available and callable as a - function. - - nlprint(list,indent=' ',sep=': ') -> prints indenting each level by 'indent' - and using 'sep' to separate the index from the value. """ - - def __init__(self): - self.depth = 0 - - def __call__(self,lst,pos='',**kw): - """Prints the nested list numbering levels.""" - kw.setdefault('indent',' ') - kw.setdefault('sep',': ') - kw.setdefault('start',0) - kw.setdefault('stop',len(lst)) - # we need to remove start and stop from kw so they don't propagate - # into a recursive call for a nested list. - start = kw['start']; del kw['start'] - stop = kw['stop']; del kw['stop'] - if self.depth == 0 and 'header' in kw.keys(): - print(kw['header']) - - for idx in range(start,stop): - elem = lst[idx] - newpos = pos + str(idx) - if type(elem)==type([]): - self.depth += 1 - self.__call__(elem, newpos+",", **kw) - self.depth -= 1 - else: - print(kw['indent']*self.depth + newpos + kw["sep"] + repr(elem)) - -nlprint = NLprinter() - - def temp_pyfile(src, ext='.py'): """Make a temporary python file, return filename and filehandle. diff --git a/IPython/utils/text.py b/IPython/utils/text.py index 35ca6bc..49f159f 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -30,7 +30,6 @@ from string import Formatter from IPython.external.path import path from IPython.testing.skipdoctest import skip_doctest_py3, skip_doctest from IPython.utils import py3compat -from IPython.utils.io import nlprint from IPython.utils.data import flatten #----------------------------------------------------------------------------- @@ -265,7 +264,7 @@ class SList(list): # arg.hideonce = False # return # -# nlprint(arg) +# nlprint(arg) # This was a nested list printer, now removed. # # print_slist = result_display.when_type(SList)(print_slist)