William Purcell wrote:
I want to use eval to evaluate wx.TextCtrl inputs. How can I keep
python from adding the __builtins__ key to mydict when I use it with
eval? Other wise I have to __delitem__('__builtins__') everytime I use
eval?
>>> mydict = {'a':2,'b':3}
>>> eval('a*b',mydict)
6
>>> mydict
{'a': 2, '__builtins__': {'IndexError': <type
'exceptions.IndexError'>, ...(I'll spare you the rest)...}, 'b': 3}
Also, how come eval has this behavior? Is it desirable?
-Bill
------------------------------------------------------------------------
--
http://mail.python.org/mailman/listinfo/python-list
no too sure, but eval('a*b', None, mydict) seems to work how you expect.
--
http://mail.python.org/mailman/listinfo/python-list