text
Shell output lists and magic argument expansion from IPython/utils/text.py.
SList
def SList(
*args, **kwargs
):
List derivative with a special access attributes.
These are normal lists, but with the special attributes:
- .l (or .list) : value as list (the list itself).
- .n (or .nlstr): value as a string, joined on newlines.
- .s (or .spstr): value as a string, joined on spaces.
- .p (or .paths): list of pathlib.Path objects (existing files only)
Any values which require transformations are computed only once and cached.
SList.<lambda>
def <lambda>():
SList.<lambda>
def <lambda>():
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
attrgetter
def attrgetter.__call__(
obj, /
):
Call self as a function.
FullEvalFormatter
def FullEvalFormatter():
A String Formatter that allows evaluation of simple expressions.
Any time a format key is not found in the kwargs, it will be tried as an expression in the kwargs namespace.
Note that this version allows slicing using [1:2], so you cannot specify a format string. Use :class:EvalFormatter to permit format strings.
Examples -------- ::
In [1]: f = FullEvalFormatter()
In [2]: f.format('{n//4}', n=8)
Out[2]: '2'
In [3]: f.format('{list(range(5))[2:4]}')
Out[3]: '[2, 3]'
In [4]: f.format('{3*2}')
Out[4]: '6'
FullEvalFormatter.vformat
def vformat(
format_string:str, args:collections.abc.Sequence[typing.Any], kwargs:collections.abc.Mapping[str, typing.Any]
)->str:
DollarFormatter
def DollarFormatter():
Formatter allowing Itpl style $foo replacement, for names and attribute access only. Standard {foo} replacement also works, and allows full evaluation of its arguments.
Examples -------- ::
In [1]: f = DollarFormatter()
In [2]: f.format('{n//4}', n=8)
Out[2]: '2'
In [3]: f.format('23 * 76 is $result', result=23*76)
Out[3]: '23 * 76 is 1748'
In [4]: f.format('$a or {b}', a=1, b=2)
Out[4]: '1 or 2'
DollarFormatter.parse
def parse(
fmt_string:str
)->collections.abc.Iterator[tuple[typing.Any, typing.Any, typing.Any, typing.Any]]: