def define_macro(self, name, themacro):
    'Define a new macro\n\n        Parameters\n        ----------\n        name : str\n            The name of the macro.\n        themacro : str or Macro\n            The action to do upon invoking the macro.  If a string, a new\n            Macro object is created by passing the string to it.\n        '
    from IPython.core import macro
    if isinstance(themacro, str):
        themacro = macro.Macro(themacro)
    if (not isinstance(themacro, macro.Macro)):
        raise ValueError('A macro must be a string or a Macro instance.')
    self.user_ns[name] = themacro
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.
def define_macro(self, name, themacro):
    'Define a new macro\n\n        Parameters\n        ----------\n        name : str\n            The name of the macro.\n        themacro : str or Macro\n            The action to do upon invoking the macro.  If a string, a new\n            Macro object is created by passing the string to it.\n        '
    from IPython.core import macro
    if isinstance(themacro, str):
        themacro = macro.Macro(themacro)
    if (not isinstance(themacro, macro.Macro)):
        raise ValueError('A macro must be a string or a Macro instance.')
    self.user_ns[name] = themacro