[Python-Dev] statically nested scopes

Jeremy Hylton jeremy@alum.mit.edu
Thu, 2 Nov 2000 13:06:12 -0500 (EST)


Don't know if you saw the discussion in the PEP or not.  I made two
arguments for being able to assign to variables bound in enclosing
scopes.

1. Every other language that supports nested lexical scoping allows
   this.  To the extent that programmers have seen these other
   languages, they will expect it to work.

2. It is possible to work around this limitation by using containers.
   If you want to have an integer that can be updated by nested
   functions, you wrap the interger in a list and make all assignments
   and references refer to list[0].  It would be unfortunate if
   programmers used this style, because it is obscure.  I'd rather see
   the language provide a way to support this style of programming
   directly. 

Jeremy