MCPcopy Create free account
hub / github.com/ipython/ipython / register

Method register

IPython/core/events.py:42–63  ·  view source on GitHub ↗

Register a new event callback. Parameters ---------- event : str The event for which to register this callback. function : callable A function to be called on the given event. It should take the same parameters as the appropriate

(self, event, function)

Source from the content-addressed store, hash-verified

40 self.callbacks = {n:[] for n in available_events}
41
42 def register(self, event, function):
43 """Register a new event callback.
44
45 Parameters
46 ----------
47 event : str
48 The event for which to register this callback.
49 function : callable
50 A function to be called on the given event. It should take the same
51 parameters as the appropriate callback prototype.
52
53 Raises
54 ------
55 TypeError
56 If ``function`` is not callable.
57 KeyError
58 If ``event`` is not one of the known events.
59 """
60 if not callable(function):
61 raise TypeError('Need a callable, got %r' % function)
62 callback_proto = available_events.get(event)
63 self.callbacks[event].append(callback_proto.adapt(function))
64
65 def unregister(self, event, function):
66 """Remove a callback from the given event."""

Callers 15

io.pyFile · 0.45
init_crash_handlerMethod · 0.45
__init__Method · 0.45
__init__Method · 0.45
init_eventsMethod · 0.45
register_post_executeMethod · 0.45
formatters.pyFile · 0.45
configure_inline_supportFunction · 0.45
test_line_cell_infoFunction · 0.45
test_multiple_magicsFunction · 0.45

Calls

no outgoing calls

Tested by 11

test_line_cell_infoFunction · 0.36
test_multiple_magicsFunction · 0.36
test_cb_errorMethod · 0.36
func1Method · 0.36
test_silent_postexecMethod · 0.36
__init__Method · 0.36