block scope?

Paul Rubin http
Sat Apr 7 00:00:59 EDT 2007


James Stroud <jstroud at mbi.ucla.edu> writes:
> Probably, with good code, block scope would be overkill, except that I
> would welcome list comprehensions to have a new scope:

Block scope is a win because it gets rid of the uncertainty of whether
the variable is used outside the block or not.  The "good code" theory
(just manually don't use the variable elsewhere) doesn't always hold
up under release deadline pressure and so on and doesn't make sense
anyway.  What's the point of NOT having block scope if you don't want
to allow for creating variables in inner blocks and using them in
other blocks?  I think it's best to require creating the variable
in a mutually enclosing scope if you want to use it that way.



More information about the Python-list mailing list