[IPython-dev] Dynamically changing the prompt from within a magic
Fri Aug 3 13:20:55 CDT 2012
On 08/03/2012 13:19, Thomas Kluyver wrote:
> On 3 August 2012 17:44, David Quigley <email@example.com>
>> I get the config entry during the __init__ call for my plugin class
>> pass it into the class I'm implementing the magic in. Once there I
>> 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
>> 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
> 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,
> IPython-dev mailing list
That makes sense now. I guess the reason the recipe works is because
create a new variable to use later and that variable is loaded in as the
template so we can manipulate it after the fact instead of manipulating
the config entry. Its good to know that whats passed into config on
startup should also be in shell instance.
More information about the IPython-dev