kernel.core.prompts — IPython v0.10 documentation

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »

# kernel.core.prompts

## Module: `kernel.core.prompts`

Inheritance diagram for `IPython.kernel.core.prompts`:

Classes for handling input/output prompts.

### Authors

- Fernando Perez <Fernando.Perez@berkeley.edu>

## Classes

### `BasePrompt`

class `IPython.kernel.core.prompts.` `BasePrompt`(cache, sep, prompt, pad_left=False)

  Bases: `object`

  Interactive prompt similar to Mathematica’s.

  `__init__`(cache, sep, prompt, pad_left=False)
  `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.

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

  `p_template`
    Template for prompt string creation
  `set_p_str`()

    Set the interpolating prompt strings.

    This must be called every time the color settings change, because the prompt_specials global may have changed.

  `write`(msg)

### `CachedOutput`

class `IPython.kernel.core.prompts.` `CachedOutput`(shell, cache_size, Pprint, colors='NoColor', input_sep='n', output_sep='n', output_sep2='', ps1=None, ps2=None, ps_out=None, pad_left=True)

  Class for printing output from calculations while keeping a cache of reults. It dynamically creates global variables prefixed with _ which contain these results.

  Meant to be used as a sys.displayhook replacement, providing numbered prompts and cache services.

  Initialize with initial and final values for cache counter (this defines the maximum size of the cache.

  `__init__`(shell, cache_size, Pprint, colors='NoColor', input_sep='n', output_sep='n', output_sep2='', ps1=None, ps2=None, ps_out=None, pad_left=True)
  `display`(arg)

    Default printer method, uses pprint.

    Do ip.set_hook(“result_display”, my_displayhook) for custom result display, e.g. when your own objects need special formatting.

  `flush`()
  `set_colors`(colors)
    Set the active color scheme and configure colors for the three prompt subsystems.
  `update`(arg)

### `Prompt1`

class `IPython.kernel.core.prompts.` `Prompt1`(cache, sep='n', prompt='In[, \#], : ', pad_left=True)

  Bases: `IPython.kernel.core.prompts.BasePrompt`

  Input interactive prompt similar to Mathematica’s.

  `__init__`(cache, sep='n', prompt='In[, \#], : ', pad_left=True)
  `auto_rewrite`()
    Print a string of the form ‘—>’ which lines up with the previous input string. Useful for systems which re-write the user input when handling automatically special syntaxes.
  `set_colors`()

### `Prompt2`

class `IPython.kernel.core.prompts.` `Prompt2`(cache, prompt=' .\D.: ', pad_left=True)

  Bases: `IPython.kernel.core.prompts.BasePrompt`

  Interactive continuation prompt.

  `__init__`(cache, prompt=' .\D.: ', pad_left=True)
  `set_colors`()
  `set_p_str`()

### `PromptOut`

class `IPython.kernel.core.prompts.` `PromptOut`(cache, sep='', prompt='Out[, \#], : ', pad_left=True)

  Bases: `IPython.kernel.core.prompts.BasePrompt`

  Output interactive prompt similar to Mathematica’s.

  `__init__`(cache, sep='', prompt='Out[, \#], : ', pad_left=True)
  `set_colors`()

## Functions

`IPython.kernel.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.kernel.core.prompts.` `str_safe`(arg)

  Convert to a string, without ever raising an exception.

  If str(arg) fails, <ERROR: ... > is returned, where ... is the exception error message.

### Navigation

- index
- modules |
- next |
- previous |
- IPython v0.10 documentation »
- The IPython API »