How is the second argument of the eval function different from the third argument?
<pre><code>class all_items(dict):
    def __getitem__(self, key):
       return 1

&gt;&gt;&gt; eval("undefined",dict(),all_items())
1
&gt;&gt;&gt; eval("undefined",all_items(),dict())
Traceback (most recent call last):
  File "&lt;pyshell#2&gt;", line 1, in &lt;module&gt;
    eval("undefined",all_items(),dict())
  File "&lt;string&gt;", line 1, in &lt;module&gt;
NameError: name 'undefined' is not defined
</code></pre>

<p>The all_items class of dictionary should return 1 for any value. Using the <strong>eval</strong> function, I want "undefined" to evaluate to 1, even though it isn't defined. This works when the all_items dictionary is the third argument of the eval statement, but not when it is the second argument. My question is why doesn't the second statment evaluate to 1? (And how could I make it work?) I'm using Python 2.5.</p>
