I think it's wonderful that Python 3000 will have the nonlocal keyword allowing complete lexical closures. I've just downloaded Python 3.0 a2 and tried the following code:<br><br>def accumulator(n):<br><br> def foo(x):
<br> nonlocal n <br> n = n + x<br> return n<br> <br> return foo<br clear="all"><br>... and it works!!! (Now let's see what Paul Graham has to say ... ;) )<br><br>However, I've also tried this:
<br><br>def accumulator(n): <br> return lambda x: nonlocal n = n + x<br><br>and unfortunately it gave me a syntax error. I don'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>"Alcuni vedono le cose come sono e dicono perché? Io sogno cose non ancora esistite e chiedo perché no?"
<br><br>G.B. Shaw