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