MCPcopy Index your code
hub / github.com/ipython/ipython / register

Method register

IPython/core/events.py:62–83  ·  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 c

(self, event: str, function: Callable[..., Any])

Source from the content-addressed store, hash-verified

60 self.print_on_error = print_on_error
61
62 def register(self, event: str, function: Callable[..., Any]) -> None:
63 """Register a new event callback.
64
65 Parameters
66 ----------
67 event : str
68 The event for which to register this callback.
69 function : callable
70 A function to be called on the given event. It should take the same
71 parameters as the appropriate callback prototype.
72
73 Raises
74 ------
75 TypeError
76 If ``function`` is not callable.
77 KeyError
78 If ``event`` is not one of the known events.
79 """
80 if not callable(function):
81 raise TypeError('Need a callable, got %r' % function)
82 if function not in self.callbacks[event]:
83 self.callbacks[event].append(function)
84
85 def unregister(self, event: str, function: Callable[..., Any]) -> None:
86 """Remove a callback from the given event."""

Callers 15

init_crash_handlerMethod · 0.45
runMethod · 0.45
__init__Method · 0.45
init_eventsMethod · 0.45
formatters.pyFile · 0.45
__init__Method · 0.45
__init__Method · 0.45
load_ipython_extensionFunction · 0.45
test_line_cell_infoFunction · 0.45

Calls

no outgoing calls

Tested by 10

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