Hi.

I'm trying to evaluate a string and getting a NameError
(it is expected, since the variable my_number wasn't provided in the "locals" dictionary).

<--snip start-->
>>> eval("my_number < 10", {"__builtins__":None}, {})
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "<string>", line 0, in ?
NameError: name 'my_number' is not defined
<--snip end-->

My question is: how can i know which variable name / symbol causes the NameError exception?
In my example, this symbol is my_number.

Using that information, I will be able to print a nice error message to the user.


Thanks
Dotan


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to