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

Method define_macro

IPython/core/interactiveshell.py:2430–2448  ·  view source on GitHub ↗

Define a new macro Parameters ---------- name : str The name of the macro. themacro : str or Macro The action to do upon invoking the macro. If a string, a new Macro object is created by passing the string to it.

(self, name, themacro)

Source from the content-addressed store, hash-verified

2428 #-------------------------------------------------------------------------
2429
2430 def define_macro(self, name, themacro):
2431 """Define a new macro
2432
2433 Parameters
2434 ----------
2435 name : str
2436 The name of the macro.
2437 themacro : str or Macro
2438 The action to do upon invoking the macro. If a string, a new
2439 Macro object is created by passing the string to it.
2440 """
2441
2442 from IPython.core import macro
2443
2444 if isinstance(themacro, str):
2445 themacro = macro.Macro(themacro)
2446 if not isinstance(themacro, macro.Macro):
2447 raise ValueError('A macro must be a string or a Macro instance.')
2448 self.user_ns[name] = themacro
2449
2450 #-------------------------------------------------------------------------
2451 # Things related to the running of system commands

Callers 2

test_macroMethod · 0.80
macroMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_macroMethod · 0.64