Show More
@@ -113,21 +113,13 b' instantiate the class yourself before registration:' | |||
|
113 | 113 | ip = get_ipython() |
|
114 | 114 | magics = StatefulMagics(ip, some_data) |
|
115 | 115 | ip.register_magics(magics) |
|
116 | ||
|
117 | ||
|
118 | In earlier versions, IPython had an API for the creation of line magics (cell | |
|
119 | magics did not exist at the time) that required you to create functions with a | |
|
120 | method-looking signature and to manually pass both the function and the name. | |
|
121 | While this API is no longer recommended, it remains indefinitely supported for | |
|
122 | backwards compatibility purposes. With the old API, you'd create a magic as | |
|
123 | follows: | |
|
124 | 116 | |
|
125 | .. sourcecode:: python | |
|
126 | 117 | |
|
127 | def func(self, line): | |
|
128 | print("Line magic called with line:", line) | |
|
129 | print("IPython object:", self.shell) | |
|
118 | .. note:: | |
|
130 | 119 | |
|
131 | ip = get_ipython() | |
|
132 | # Declare this function as the magic %mycommand | |
|
133 | ip.define_magic('mycommand', func) | |
|
120 | In early IPython versions 0.12 and before the line magics were | |
|
121 | created using a :func:`define_magic` API function. This API has been | |
|
122 | replaced with the above in IPython 0.13 and then completely removed | |
|
123 | in IPython 5. Maintainers of IPython extensions that still use the | |
|
124 | :func:`define_magic` function are advised to adjust their code | |
|
125 | for the current API. |
General Comments 0
You need to be logged in to leave comments.
Login now