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

Thomas Kluyver takowl at gmail.com
Fri Aug 3 13:19:32 EDT 2012


On 3 August 2012 17:44, David Quigley <dpquigl at davequigley.com> wrote:
> I get the config entry during the __init__ call for my plugin class and
> pass it into the class I'm implementing the magic in. Once there I save
> it off and then use it later in the magic. The problem I'm having is
> that 1) unless I set the config.PromptManager.in_template field first it
> doesn't exist (no default?) and 2) when I do set that value it doesn't
> actually change the prompt.
>
> Is there something that I'm missing here?

By the sounds of it, you're changing the config itself. When the
application is started up, the config is applied to the relevant
objects, and if there's no value in the config, it uses the default
values for traits. After that, changing the config will have no
effect.

You need to change the attribute ip.prompt_manager.in_template
directly (where ip is the shell object passed into your
load_ipython_extension() function).

Hope that helps,
Thomas



More information about the IPython-dev mailing list