Important
This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.
If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).
Module:terminal.interactiveshell
IPython terminal interface using prompt_toolkit
2 ClassesBases: History
Prompt toolkit has it’s own way of handling history, Where it assumes it can Push/pull from history.
Add string to the history.
This should be a generator that yields str
instances.
It should yield the most recent items first, because they are the most important. (The history can already be used, even when it’s only partially loaded.)
Store the string in persistent storage.
Bases: InteractiveShell
Create a configurable given a config config.
config (Config) – If this is empty, default values are used. If config is a Config
instance, it will be used to configure the instance.
parent (Configurable instance, optional) – The parent Configurable instance of this object.
Notes
Subclasses of Configurable must call the __init__()
method of Configurable
before doing anything else and using super()
:
class MyConfigurable(Configurable): def __init__(self, config=None): super(MyConfigurable, self).__init__(config=config) # Then any other code you need to finish initialization.
This ensures that instances will be configured properly.
Automatically add/delete closing bracket or quote when opening bracket or quote is entered/deleted. Brackets: (), [], {} Quotes: ‘’, “”
Overridden from the parent class to use fancy rewriting prompt
Autoformatter to reformat Terminal code. Can be 'black'
, 'yapf'
or None
Specifies from which source automatic suggestions are provided. Can be set to 'NavigableAutoSuggestFromHistory'
(up and down swap suggestions), 'AutoSuggestFromHistory'
, or None
to disable automatic suggestions. Default is 'NavigableAutoSuggestFromHistory
’.
Set to confirm when you try to exit IPython with an EOF (Control-D in Unix, Control-Z/Enter in Windows). By typing ‘exit’ or ‘quit’, you can force a direct exit without any confirmation.
Version of debugger where KeyboardInterrupt exits the debugger altogether.
File in which to store and read history
Options for displaying tab completions, ‘column’, ‘multicolumn’, and ‘readlinelike’. These options are for prompt_toolkit
, see prompt_toolkit
documentation for more information.
Shortcut style to use at the prompt. ‘vi’ or ‘emacs’.
Set the editor used by IPython (default to $EDITOR/vi/notepad).
Add shortcuts from ‘emacs’ insert mode to ‘vi’ insert mode.
Allows to enable/disable the prompt toolkit history search
Enable vi (v) or Emacs (C-X C-E) shortcuts to open an external editor. This is in addition to the F2 binding, which is always enabled.
Provide an alternative handler to be called when the user presses Return. This is an advanced option intended for debugging, which may be changed or removed in later releases.
Highlight matching brackets.
Deprecated, and has not effect, use IPython themes
The name or class of a Pygments style to use for syntax highlighting. To see available styles, run pygmentize -L styles
.
Override highlighting format for specific tokens
Extra arguments to pass to llm_provider_class
constructor.
This is used to – for example – set the model_id
Fully Qualifed name of a function that takes an IPython history manager and return a prefix to pass the llm provider in addition to the current buffer text.
You can use:
As default value. input_history
(default), will use all the input history of current IPython session
This is a provisional API in IPython 8.32, before stabilisation in 9.0, it may change without warnings.
class to use for the NavigableAutoSuggestFromHistory
to request completions from a LLM, this should inherit from jupyter_ai_magics:BaseProvider
and implement stream_inline_completions
minimum characters for filling with ellipsis in file completions
beam in vi insert mode, block in nav mode, underscore in replace mode.
Cursor shape changes depending on vi mode
Enable mouse support in the prompt (Note: prevents selecting text with the mouse)
Display the current vi mode (when using vi editing mode).
4d}/{rel_line:+03d} | ‘ This will display the current line number, with leading space and a width of at least 4 character, as well as the relative line number 0 padded and always with a + or - sign. Note that when using Emacs mode the prompt of the first line may not update.
The format for line numbering, will be passed line
(int, 1 based) the current line number and rel_line
the relative line number. for example to display both you can use the following template string
c.TerminalInteractiveShell.prompt_line_number_format=’{line
Class used to generate Prompt token for prompt_toolkit
Add, disable or modifying shortcuts.
Each entry on the list should be a dictionary with command
key identifying the target function executed by the shortcut and at least one of the following:
match_keys
: list of keys used to match an existing shortcut,
match_filter
: shortcut filter used to match an existing shortcut,
new_keys
: list of keys to set,
new_filter
: a new shortcut filter to set
The filters have to be composed of pre-defined verbs and joined by one of the following conjunctions: &
(and), |
(or), ~
(not). The pre-defined verbs are:
always
never
has_line_below
has_line_above
is_cursor_at_the_end_of_line
has_selection
has_suggestion
vi_mode
vi_insert_mode
emacs_insert_mode
emacs_like_insert_mode
has_completions
insert_mode
default_buffer_focused
search_buffer_focused
ebivim
supports_suspend
is_windows_os
auto_match
focused_insert
not_inside_unclosed_string
readline_like_completions
preceded_by_paired_double_quotes
preceded_by_paired_single_quotes
preceded_by_raw_str_prefix
preceded_by_two_double_quotes
preceded_by_two_single_quotes
followed_by_closing_paren_or_end
preceded_by_opening_round_paren
preceded_by_opening_bracket
preceded_by_opening_brace
preceded_by_double_quote
preceded_by_single_quote
followed_by_closing_round_paren
followed_by_closing_bracket
followed_by_closing_brace
followed_by_double_quote
followed_by_single_quote
navigable_suggestions
cursor_in_leading_ws
pass_through
To disable a shortcut set new_keys
to an empty list. To add a shortcut add key create
with value True
.
When modifying/disabling shortcuts, match_keys
/match_filter
can be omitted if the provided specification uniquely identifies a shortcut to be modified/disabled. When modifying a shortcut new_filter
or new_keys
can be omitted which will result in reuse of the existing filter/keys.
Only shortcuts defined in IPython (and not default prompt-toolkit shortcuts) can be modified or disabled. The full list of shortcuts, command identifiers and filters is available under IPython shortcuts.
Here is an example:
c.TerminalInteractiveShell.shortcuts = [ { "new_keys": ["c-q"], "command": "prompt_toolkit:named_commands.capitalize_word", "create": True, }, { "new_keys": ["c-j"], "command": "prompt_toolkit:named_commands.beginning_of_line", "create": True, }, ]
Use raw_input
for the REPL, without completion and prompt colors.
Useful when controlling IPython as a subprocess, and piping STDIN/OUT/ERR. Known usage are: IPython’s own testing machinery, and emacs’ inferior-python subprocess (assuming you have set python-shell-interpreter
to “ipython”) available through the built-in M-x run-python
and third party packages such as elpy.
This mode default to True
if the IPY_TEST_SIMPLE_PROMPT
environment variable is set, or the current terminal is not a tty. Thus the Default value reported in –help-all, or config will often be incorrectly reported.
Number of line at the bottom of the screen to reserve for the tab completion menu, search history, …etc, the height of these menus will at most this value. Increase it is you prefer long and skinny menus, decrease for short and wide.
Switch prompts to classic for %doctest_mode
Call the given cmd in a subprocess using os.system on Windows or subprocess.call using the system shell on other platforms.
cmd (str) – Command to execute.
Automatically set the terminal title
{cwd}.
Customize the terminal title format. This is a python format string. Available substitutions are
The time in milliseconds that is waited for a mapped key sequence to complete.
Use 24bit colors instead of 256 colors in prompt highlighting. If your terminal supports true color, the following command should print TRUECOLOR
in orange:
printf "\x1b[38;2;255;100;0mTRUECOLOR\x1b[0m\n"
The time in milliseconds that is waited for a key code to complete.
We do not need to protect against error, this is taken care at a higher level where any reformat error is ignored. Indeed we may call reformatting on incomplete code.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4