##// END OF EJS Templates
docs
Matthias Bussonnier -
Show More
@@ -17,22 +17,29 b' For example::'
17 def __init__(self, ip):
17 def __init__(self, ip):
18 self.shell = ip
18 self.shell = ip
19 self.last_x = None
19 self.last_x = None
20
20
21 def pre_execute(self):
21 def pre_execute(self):
22 self.last_x = self.shell.user_ns.get('x', None)
22 self.last_x = self.shell.user_ns.get('x', None)
23
23
24 def pre_run_cell(self, info):
24 def pre_run_cell(self, info):
25 print('Cell code: "%s"' % info.raw_cell)
25 print('info.raw_cell =', info.raw_cell)
26
26 print('info.store_history =', info.store_history)
27 print('info.silent =', info.silent)
28 print('info.shell_futures =', info.shell_futures)
29 print('info.cell_id =', info.cell_id)
30 print(dir(info))
31
27 def post_execute(self):
32 def post_execute(self):
28 if self.shell.user_ns.get('x', None) != self.last_x:
33 if self.shell.user_ns.get('x', None) != self.last_x:
29 print("x changed!")
34 print("x changed!")
30
35
31 def post_run_cell(self, result):
36 def post_run_cell(self, result):
32 print('Cell code: "%s"' % result.info.raw_cell)
37 print('result.execution_count = ', result.execution_count)
33 if result.error_before_exec:
38 print('result.error_before_exec = ', result.error_before_exec)
34 print('Error before execution: %s' % result.error_before_exec)
39 print('result.error_in_exec = ', result.error_in_exec)
35
40 print('result.info = ', result.info)
41 print('result.result = ', result.result)
42
36 def load_ipython_extension(ip):
43 def load_ipython_extension(ip):
37 vw = VarWatcher(ip)
44 vw = VarWatcher(ip)
38 ip.events.register('pre_execute', vw.pre_execute)
45 ip.events.register('pre_execute', vw.pre_execute)
@@ -40,6 +47,13 b' For example::'
40 ip.events.register('post_execute', vw.post_execute)
47 ip.events.register('post_execute', vw.post_execute)
41 ip.events.register('post_run_cell', vw.post_run_cell)
48 ip.events.register('post_run_cell', vw.post_run_cell)
42
49
50 .. versionadded:: 8.3
51
52 Since IPython 8.3 and ipykernel 6.12.1, the ``info`` objects in the callback
53 now have a the ``cell_id`` that will be set to the value sent by the
54 frontened, when those send it.
55
56
43
57
44 Events
58 Events
45 ======
59 ======
@@ -3,6 +3,14 b''
3 ============
3 ============
4
4
5
5
6 .. _version 8.3.0:
7
8 IPython 8.3.0
9 -------------
10
11 - :ghpull:`13600`, ``pre_run_*``-hooks will now have a ``cell_id`` attribute on
12 the info object when frontend provide it.
13
6 .. _version 8.2.0:
14 .. _version 8.2.0:
7
15
8 IPython 8.2.0
16 IPython 8.2.0
General Comments 0
You need to be logged in to leave comments. Login now