Carl Banks invalidemail at
Wed Mar 16 13:54:17 CET 2005

Michele Simionato wrote:
> Carl Banks:
> > If Python did it the way Scheme did, this would be pretty useless.
> But notice that Scheme has no problems whatsoever:
> (define (toplevel)
>   (define a 1)
>   (define (f)
>     (display a))
>   (set! a 2)
>   (f))
> (toplevel)
> prints 2 the same as in Python.

Hmm. On closer inspection, I'm going to have to amend my implictation
of Scheme: the example poster was cheating.  Scheme and Python both do
closures the same way.  However, the Scheme snippet in the original
example used a let-block.  I.e., it introduced a new scope, whereas the
Python example did not (because it doesn't have anything like let).


More information about the Python-list mailing list