##// END OF EJS Templates
Small doc cleanup.
Fernando Perez -
Show More
@@ -1,55 +1,54 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 """ Prettier (non-repr-like) and more informative printer for LSString """
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
25 24
26 25 result_display = generic(result_display)
27 26
28 27 def inspect_object(obj):
29 28 """ Called when you do obj? """
30 29 raise TryNext
31 30 inspect_object = generic(inspect_object)
32 31
33 32 def complete_object(obj, prev_completions):
34 33 """ Custom completer dispatching for python objects
35 34
36 35 obj is the object itself.
37 36 prev_completions is the list of attributes discovered so far.
38 37
39 38 This should return the list of attributes in obj. If you only wish to
40 39 add to the attributes already discovered normally, return
41 40 own_attrs + prev_completions.
42 41 """
43 42
44 43 raise TryNext
45 44 complete_object = generic(complete_object)
46 45
47 46 #import os
48 47 #def my_demo_complete_object(obj, prev_completions):
49 48 # """ Demo completer that adds 'foobar' to the completions suggested
50 49 # for any object that has attribute (path), e.g. 'os'"""
51 50 # if hasattr(obj,'path'):
52 51 # return prev_completions + ['foobar']
53 52 # raise TryNext
54 53 #
55 54 #my_demo_complete_object = complete_object.when_type(type(os))(my_demo_complete_object)
General Comments 0
You need to be logged in to leave comments. Login now