Cannot pass UserDict to eval()?
Frank Niessink
frankn=nuws at cs.vu.nl
Mon Aug 14 16:20:37 EDT 2000
Hi,
This works:
>>> eval('x+1',{},{'x':1})
2
But this doesn't:
>>> import UserDict
>>> u = UserDict.UserDict({'x':1})
>>> eval('x+1',{},u)
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: eval, argument 3: expected dictionary, instance found
Why are instances not allowed?
Cheers, Frank
--
For light to reach the other side of the Galaxy, for it to reach Damogran for
instance, takes rather longer: five hundred thousand years. The record for
hitch hiking this distance is just under five years, but you don't get to see
much on the way.
-- Douglas Adams, 'The Hitch Hiker's Guide to the Galaxy'
More information about the Python-list
mailing list