I've been using Python 2 for several months now, and commonly use eval() to dynamically set variables. For example:
num_ls = [1,2,3]
let_ls = ['a', 'b', 'c']
what2plot = 'num'
list2plot = eval(what2plot + '_ls')
Today, all of my code written this day suddenly hits an error when I use eval().
The error is:
Traceback (most recent call last):
File "", line 1, in list2plot = eval(what2plot + '_ls')
File "/anaconda/lib/python2.7/site-packages/pandas/computation/eval.py", line 266, in eval ret = eng_inst.evaluate()
File "/anaconda/lib/python2.7/site-packages/pandas/computation/engines.py", line 76, in evaluate res = self._evaluate()
File "/anaconda/lib/python2.7/site-packages/pandas/computation/engines.py", line 123, in _evaluate return ne.evaluate(s, local_dict=scope, truediv=truediv)
File "/anaconda/lib/python2.7/site-packages/numexpr/necompiler.py", line 789, in evaluate zip(names, arguments)]
File "/anaconda/lib/python2.7/site-packages/numexpr/necompiler.py", line 686, in getType raise ValueError("unknown type %s" % a.dtype.name)
ValueError: unknown type unicode1792