Module:core.splitinput

Simple utility for splitting user input. This is used by both inputsplitter andprefilter.

1 Class

classIPython.core.splitinput.LineInfo(line:str,continue_prompt:bool=False)

Bases:object

A single line of input and associated info.

Includes the following as properties:

line

The original, raw line

continue_prompt

Is this line a continuation in a sequence of multiline input?

pre

Any leading whitespace.

esc

The escape character(s) in pre or the empty string if there isn’t one.Note that ‘!!’ and ‘??’ are possible values for esc. Otherwise it willalways be a single character.

ifun

The ‘function part’, which is basically the maximal initial sequenceof valid python identifiers and the ‘.’ character. This is what ischecked for alias and magic transformations, used for auto-calling,etc. In contrast to Python identifiers, it may start with “%” and contain“*”.

the_rest

Everything else on the line.

raw_the_rest

the_rest without whitespace stripped.

__init__(line:str,continue_prompt:bool=False)None
ofind(ip)OInfo

Do a full, attribute-walking lookup of the ifun in the variousnamespaces for the given IPython InteractiveShell instance.

Return a dict with keys: {found, obj, ospace, ismagic}

Note: can cause state changes because of calling getattr, but shouldonly be run if autocall is on and if the line hasn’t matched anyother, less dangerous handlers.

Does cache the results of the call, so can be called multiple timeswithout worrying aboutfurther damaging state.

Deprecated since version 9.8:Useshell._ofind(line_info.ifun) directly instead.

1 Function

IPython.core.splitinput.split_user_input(line:str,pattern:Pattern[str]|None=None)tuple[str,str,str,str]

Split user input into initial whitespace, escape character, function partand the rest.