[IPython-dev] Dynamically changing the prompt from within a magic

David Quigley dpquigl@davequigley....
Fri Aug 3 13:41:49 CDT 2012


On 08/03/2012 13:29, Bradley M. Froehle wrote:
> Otherwise, the function magic function would look something like:
>
> from IPython.core.magic import magics_class, Magics, line_magic
> from IPython.utils import text
> @magics_class
> class PromptMagics(Magics):
>
>     @line_magic
>     def prompt(self, line):
>         """Get or update the input prompt.
>
>         Usage:
>           %prompt [in_template]
>
>         If called without arguments, return the prompt `in_template`.
>         Otherwise set the `in_template` to the given value.
>         """
>         pm = self.shell.prompt_manager
>         if line:
>             pm.in_template = text.unquote_ends(line)
>         else:
>             return pm.in_template
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev

Thank you for the magic implementation. It was very helpful.


More information about the IPython-dev mailing list