Reputation: 273
I am looking for a way to evaluate string syntax that allows for indexing.
Example:
string = '[1,2,3][0]'
foo = literal_eval( string )
In this case, I want foo to equal 1
ast literal_eval does not support this because
The code is untrusted so I cannot use the python eval()
function.
Any thoughts?
Upvotes: 0
Views: 124