##// END OF EJS Templates
Incorporate suggestions from Ville.
Robert Kern -
Show More
@@ -4,7 +4,8 b' Register pretty-printers for types using pretty.for_type() or'
4 4 pretty.for_type_by_name(). For example, to make a pretty-printer for numpy dtype
5 5 objects, add the following to your ipy_user_conf.py::
6 6
7 from IPython.Extensions import ipy_pretty, pretty
7 from IPython.Extensions import ipy_pretty
8 from IPython.external import pretty
8 9
9 10 def dtype_pprinter(obj, p, cycle):
10 11 if cycle:
@@ -31,7 +32,7 b' objects, add the following to your ipy_user_conf.py::'
31 32 import IPython.ipapi
32 33 from IPython.genutils import Term
33 34
34 from IPython.Extensions import pretty
35 from IPython.external import pretty
35 36
36 37 ip = IPython.ipapi.get()
37 38
@@ -41,8 +42,9 b' def pretty_result_display(self, arg):'
41 42 Called for displaying the result to the user.
42 43 """
43 44
44 if self.rc.pprint:
45 out = pretty.pretty(arg, verbose=getattr(self.rc, 'pretty_verbose', False))
45 if ip.options.pprint:
46 verbose = getattr(ip.options, 'pretty_verbose', False)
47 out = pretty.pretty(arg, verbose=verbose)
46 48 if '\n' in out:
47 49 # So that multi-line strings line up with the left column of
48 50 # the screen, instead of having the output prompt mess up
@@ -50,12 +52,7 b' def pretty_result_display(self, arg):'
50 52 Term.cout.write('\n')
51 53 print >>Term.cout, out
52 54 else:
53 # By default, the interactive prompt uses repr() to display results,
54 # so we should honor this. Users who'd rather use a different
55 # mechanism can easily override this hook.
56 print >>Term.cout, repr(arg)
57 # the default display hook doesn't manipulate the value to put in history
58 return None
59
60 ip.set_hook('result_display', pretty_result_display)
55 raise TryNext
56
57 ip.set_hook('result_display', pretty_result_display, priority=99)
61 58
1 NO CONTENT: file renamed from IPython/Extensions/pretty.py to IPython/external/pretty.py
General Comments 0
You need to be logged in to leave comments. Login now