Show More
@@ -17,22 +17,29 b' For example::' | |||
|
17 | 17 | def __init__(self, ip): |
|
18 | 18 | self.shell = ip |
|
19 | 19 | self.last_x = None |
|
20 | ||
|
20 | ||
|
21 | 21 | def pre_execute(self): |
|
22 | 22 | self.last_x = self.shell.user_ns.get('x', None) |
|
23 | ||
|
23 | ||
|
24 | 24 | def pre_run_cell(self, info): |
|
25 |
print(' |
|
|
26 | ||
|
25 | print('info.raw_cell =', info.raw_cell) | |
|
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 | 32 | def post_execute(self): |
|
28 | 33 | if self.shell.user_ns.get('x', None) != self.last_x: |
|
29 | 34 | print("x changed!") |
|
30 | ||
|
35 | ||
|
31 | 36 | def post_run_cell(self, result): |
|
32 | print('Cell code: "%s"' % result.info.raw_cell) | |
|
33 |
if result.error_before_exec |
|
|
34 |
|
|
|
35 | ||
|
37 | print('result.execution_count = ', result.execution_count) | |
|
38 | print('result.error_before_exec = ', result.error_before_exec) | |
|
39 | print('result.error_in_exec = ', result.error_in_exec) | |
|
40 | print('result.info = ', result.info) | |
|
41 | print('result.result = ', result.result) | |
|
42 | ||
|
36 | 43 | def load_ipython_extension(ip): |
|
37 | 44 | vw = VarWatcher(ip) |
|
38 | 45 | ip.events.register('pre_execute', vw.pre_execute) |
@@ -40,6 +47,13 b' For example::' | |||
|
40 | 47 | ip.events.register('post_execute', vw.post_execute) |
|
41 | 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 | 58 | Events |
|
45 | 59 | ====== |
General Comments 0
You need to be logged in to leave comments.
Login now