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