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

Function no_var_expand

IPython/core/magic.py:271–284  ·  view source on GitHub ↗

Mark a magic function as not needing variable expansion By default, IPython interprets `{a}` or `$a` in the line passed to magics as variables that should be interpolated from the interactive namespace before passing the line to the magic function. This is not always desirable, e.g.

(magic_func)

Source from the content-addressed store, hash-verified

269
270
271def no_var_expand(magic_func):
272 """Mark a magic function as not needing variable expansion
273
274 By default, IPython interprets `{a}` or `$a` in the line passed to magics
275 as variables that should be interpolated from the interactive namespace
276 before passing the line to the magic function.
277 This is not always desirable, e.g. when the magic executes Python code
278 (%timeit, %time, etc.).
279 Decorate magics with `@no_var_expand` to opt-out of variable expansion.
280
281 .. versionadded:: 7.3
282 """
283 setattr(magic_func, MAGIC_NO_VAR_EXPAND_ATTR, True)
284 return magic_func
285
286
287# Create the actual decorators for public use

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected