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