IPython Documentation

Table Of Contents

Previous topic

Module: core.profiledir

Next topic

Module: core.pylabtools

This Page

Warning

This documentation is for an old version of IPython. You can find docs for newer versions here.

Module: core.prompts

Classes for handling input/output prompts.

Authors:

  • Fernando Perez
  • Brian Granger
  • Thomas Kluyver

3 Classes

class IPython.core.prompts.LazyEvaluate(func, *args, **kwargs)

Bases: object

This is used for formatting strings with values that need to be updated at that time, such as the current time or working directory.

__init__(func, *args, **kwargs)
class IPython.core.prompts.UserNSFormatter(shell)

Bases: string.Formatter

A Formatter that falls back on a shell’s user_ns and __builtins__ for name resolution

__init__(shell)
class IPython.core.prompts.PromptManager(shell, **kwargs)

Bases: IPython.config.configurable.Configurable

This is the primary interface for producing IPython’s prompts.

__init__(shell, **kwargs)
render(name, color=True, just=None, **kwargs)

Render the selected prompt.

Parameters:

name : str

Which prompt to render. One of ‘in’, ‘in2’, ‘out’, ‘rewrite’

color : bool

If True (default), include ANSI escape sequences for a coloured prompt.

just : bool

If True, justify the prompt to the width of the last prompt. The default is stored in self.justify.

**kwargs : :

Additional arguments will be passed to the string formatting operation, so they can override the values that would otherwise fill in the template.

Returns:

A string containing the rendered prompt. :

update_prompt(name, new_template=None)

This is called when a prompt template is updated. It processes abbreviations used in the prompt template (like #) and calculates how many invisible characters (ANSI colour escapes) the resulting prompt contains.

It is also called for each prompt on changing the colour scheme. In both cases, traitlets should take care of calling this automatically.

3 Functions

IPython.core.prompts.multiple_replace(dict, text)

Replace in ‘text’ all occurences of any key in the given dictionary by its corresponding value. Returns the new string.

IPython.core.prompts.cwd_filt(depth)

Return the last depth elements of the current working directory.

$HOME is always replaced with ‘~’. If depth==0, the full path is returned.

IPython.core.prompts.cwd_filt2(depth)

Return the last depth elements of the current working directory.

$HOME is always replaced with ‘~’. If depth==0, the full path is returned.