Show More
@@ -1,24 +1,23 b'' | |||||
1 | from IPython.ipapi import TryNext |
|
1 | ''' 'Generic' functions for extending IPython. | |
2 | from IPython.external.simplegeneric import generic |
|
|||
3 |
|
|
2 | ||
4 | ''' 'Generic' functions for extending IPython |
|
3 | See http://cheeseshop.python.org/pypi/simplegeneric. | |
5 |
|
4 | |||
6 | See http://cheeseshop.python.org/pypi/simplegeneric |
|
5 | Here is an example from genutils.py: | |
7 |
|
||||
8 | Here's an example from genutils.py: |
|
|||
9 |
|
6 | |||
10 | def print_lsstring(arg): |
|
7 | def print_lsstring(arg): | |
11 |
" |
|
8 | "Prettier (non-repr-like) and more informative printer for LSString" | |
12 | print "LSString (.p, .n, .l, .s available). Value:" |
|
9 | print "LSString (.p, .n, .l, .s available). Value:" | |
13 | print arg |
|
10 | print arg | |
14 |
|
11 | |||
15 | print_lsstring = result_display.when_type(LSString)(print_lsstring) |
|
12 | print_lsstring = result_display.when_type(LSString)(print_lsstring) | |
16 |
|
13 | |||
17 | (Yes, the nasty syntax is for python 2.3 compatibility. Your own extensions |
|
14 | (Yes, the nasty syntax is for python 2.3 compatibility. Your own extensions | |
18 | can use the niftier decorator syntax) |
|
15 | can use the niftier decorator syntax introduced in Python 2.4). | |
19 |
|
||||
20 | ''' |
|
16 | ''' | |
21 |
|
17 | |||
|
18 | from IPython.ipapi import TryNext | |||
|
19 | from IPython.external.simplegeneric import generic | |||
|
20 | ||||
22 | def result_display(result): |
|
21 | def result_display(result): | |
23 | """ print the result of computation """ |
|
22 | """ print the result of computation """ | |
24 | raise TryNext |
|
23 | raise TryNext |
General Comments 0
You need to be logged in to leave comments.
Login now