+ 1
As long as the input is one of the types that ast.literal_eval accepts, it works the same as eval. That said, how either of them works is by invoking the Python parser and then passing the AST to the interpreter which would then convert it into corresponding function calls to the underlying platform. It may sound like black magic if you have written a simple interpreter yourself. So, please read through this brilliantly written walk through on how to build an interpreter: https://ruslanspivak.com/lsbasi-part1/
4th Jul 2017, 10:51 AM
Venkatesh Pitta
Venkatesh Pitta - avatar