I have a function that returns a string that can be interpreted as a Boolean
def foo():
return "not(True and False)"
How can I return the actual Boolean value, in this case True?
I have a function that returns a string that can be interpreted as a Boolean
def foo():
return "not(True and False)"
How can I return the actual Boolean value, in this case True?
You could use eval:
def foo():
return eval("not(True and False)")
Even tho it is virtually the only solution, but it is still not safe.
Check this link for why it is not safe.