This is a development version (latest) and may be unstable. Go to latest (9.13.0)
{ } Raw JSON

bundles / IPython latest / IPython / utils / text / FullEvalFormatter

class

IPython.utils.text:FullEvalFormatter

source: /IPython/utils/text.py :463

Signature

class   FullEvalFormatter ( )

Members

Summary

A String Formatter that allows evaluation of simple expressions.

Extended Summary

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 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'

Aliases

  • IPython.utils.text.FullEvalFormatter