From f6a7c2d10ee74e162c91ed743f227a00e6420eef 2009-03-05 08:37:34 From: Robert Kern Date: 2009-03-05 08:37:34 Subject: [PATCH] Incorporate suggestions from Ville. --- diff --git a/IPython/Extensions/ipy_pretty.py b/IPython/Extensions/ipy_pretty.py index 78da012..297a9bf 100644 --- a/IPython/Extensions/ipy_pretty.py +++ b/IPython/Extensions/ipy_pretty.py @@ -4,7 +4,8 @@ Register pretty-printers for types using pretty.for_type() or pretty.for_type_by_name(). For example, to make a pretty-printer for numpy dtype objects, add the following to your ipy_user_conf.py:: - from IPython.Extensions import ipy_pretty, pretty + from IPython.Extensions import ipy_pretty + from IPython.external import pretty def dtype_pprinter(obj, p, cycle): if cycle: @@ -31,7 +32,7 @@ objects, add the following to your ipy_user_conf.py:: import IPython.ipapi from IPython.genutils import Term -from IPython.Extensions import pretty +from IPython.external import pretty ip = IPython.ipapi.get() @@ -41,8 +42,9 @@ def pretty_result_display(self, arg): Called for displaying the result to the user. """ - if self.rc.pprint: - out = pretty.pretty(arg, verbose=getattr(self.rc, 'pretty_verbose', False)) + if ip.options.pprint: + verbose = getattr(ip.options, 'pretty_verbose', False) + out = pretty.pretty(arg, verbose=verbose) if '\n' in out: # So that multi-line strings line up with the left column of # the screen, instead of having the output prompt mess up @@ -50,12 +52,7 @@ def pretty_result_display(self, arg): Term.cout.write('\n') print >>Term.cout, out else: - # By default, the interactive prompt uses repr() to display results, - # so we should honor this. Users who'd rather use a different - # mechanism can easily override this hook. - print >>Term.cout, repr(arg) - # the default display hook doesn't manipulate the value to put in history - return None - -ip.set_hook('result_display', pretty_result_display) + raise TryNext + +ip.set_hook('result_display', pretty_result_display, priority=99) diff --git a/IPython/Extensions/pretty.py b/IPython/external/pretty.py similarity index 100% rename from IPython/Extensions/pretty.py rename to IPython/external/pretty.py