3 ms·
I've done this before with Python, making AST literals directly out of tokens. It's potentially dangerous however, similar to eval-ing input. It can be done saf
by lucian1900 13y ago
I've done this before with Python, making AST literals directly out of tokens. It's potentially dangerous however, similar to eval-ing input. It can be done safely with care.
- icebraining 13y agoYou can use ast.literal_eval[1] which is supposedly safe (only accepts literal values, not code). [1] http://docs.python.org/2/library/ast.html#ast.literal_eval http://docs.python.org/2/library/ast.html#ast.literal_eval