IPython Documentation

Table Of Contents

Previous topic

Module: core.profiledir

Next topic

Module: core.pylabtools

This Page

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)
color_scheme

A trait for unicode strings.

color_scheme_table

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

in2_template

A trait for unicode strings.

in_template

A trait for unicode strings.

invisible_chars

An instance of a Python dict.

justify

A boolean (True, False) trait.

lazy_evaluate_fields

An instance of a Python dict.

out_template

A trait for unicode strings.

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. :

shell

A trait whose value must be an instance of a specified class.

The value can also be an instance of a subclass of the specified class.

templates

An instance of a Python dict.

txtwidth

An int trait.

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.

width

An int trait.

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.