[Python-Dev] Using defaultdict as globals/locals for eval() (original) (raw)

Raymond Hettinger python@rcn.com
Mon, 28 Oct 2002 08:43:59 -0500


I created a derived class of the standard `dict' that fills in a default value when a key is not found. This is exactly the same as Guido describes in his "descintro" paper. I tried to use this dictionary as the "globals" parameter with eval(). As Guido already describes in his paper, this doesn't work.

I've wanted this for years and think it would be an important improvement. Unfortunately, it appears to be a problem without a simple solution.

Raymond Hettinger