PyDocs

Nav

Python Language Services

literal_eval

ast

function (source)
  • literal_eval(node_or_string)
Evaluate an expression node or a string containing only a Python
expression.  The string or node provided may only consist of the following
Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
sets, booleans, and None.

Caution: A complex expression can overflow the C stack and cause a crash.
Changed in 3.2, 3.9, 3.10
  • 3.2: Now allows bytes and set literals.
  • 3.9: Now supports creating empty sets with 'set()'.
  • 3.10: For string inputs, leading spaces and tabs are now stripped.
0 Examples
No examples for ast/literal_eval.
See Also
No see-alsos for ast/literal_eval
0 Notes
No notes for literal_eval