As you know, if we simply do:
>>> a > 0
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
a > 0
NameError: name 'a' is not defined
Is there a way of catching the exception/error and extracting from it the value 'a'.
I need this because I'm eval
uating some dynamically created expressions, and would like to retrieve the names which are not defined in them.
Hope I made myself clear. Thanks! Manuel
eval
? If you want to create a Python shell, this is not the right tool. If you want to create an expression evaluator for your application, this is not the right tool. – Quadrisect