##// END OF EJS Templates
Add docs
Matthias Bussonnier -
Show More
@@ -134,6 +134,18 b' instantiate the class yourself before registration:'
134 :func:`define_magic` function are advised to adjust their code
134 :func:`define_magic` function are advised to adjust their code
135 for the current API.
135 for the current API.
136
136
137
138 Accessing user namespace and local scope
139 ========================================
140
141 When creating line magics, you may need to access surrounding scope to get user
142 variables (e.g when called inside functions). IPython provide the
143 ``@needs_local_scope`` decorator that can be imported from
144 ``IPython.core.magics``. When decorated with ``@needs_local_scope`` a magic will
145 be passed ``local_ns`` as an argument. As a convenience ``@needs_local_scope``
146 can also be applied to cell magics even if cell magics cannot appear at local
147 scope context.
148
137 Complete Example
149 Complete Example
138 ================
150 ================
139
151
General Comments 0
You need to be logged in to leave comments. Login now