I think it&#39;s wonderful that Python 3000 will have the nonlocal keyword allowing complete lexical closures. I&#39;ve just downloaded Python 3.0 a2 and tried the following code:<br><br>def accumulator(n):<br><br>&nbsp;&nbsp;&nbsp; def foo(x):
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nonlocal n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; n = n + x<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return n<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; return foo<br clear="all"><br>... and it works!!! (Now let&#39;s see what Paul Graham has to say ... ;) )<br><br>However, I&#39;ve also tried this:
<br><br>def accumulator(n):&nbsp;&nbsp;  <br>&nbsp;&nbsp;&nbsp; return lambda x: nonlocal n = n + x<br><br>and unfortunately it gave me a syntax error. I don&#39;t see any reason why this kind of code should not be possible.<br><br>What do you all think?
<br><br><br>-- <br>Rocco Rossi<br><br>-----------------------------------------------------------------<br><br>&quot;Alcuni vedono le cose come sono e dicono perché? Io sogno cose non ancora esistite e chiedo perché no?&quot;
<br><br>G.B. Shaw