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

Thomas Kluyver takowl@gmail....
Fri Aug 3 12:19:32 CDT 2012


On 3 August 2012 17:44, David Quigley <dpquigl@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