previous discussion at http://mail.python.org/pipermail/python-dev/2005-September/056677.html
I don't agree with the author that >>> i = 3 >>> for i in range(11): pass ... >>> i 10 is much less confusing than i returning 3. furthermore, his C example makes it obvious that "i" will be available in the scope after the loop. There's no way to know now, but I think mistakes would be less frequent. Additionally, what are others' opinions about this "pseudo-namespace" (i.e. scoping) being slow? Admittedly, I don't know much about the current parser's implementation, but it doesn't seem like scoping necessitates slow parsing -- considering it's done in other languages, and python functions have reasonable scope. >>> def do_nothing(i): i = 3 ... >>> do_nothing(1) >>> i 10 Nicholas On Wed, Apr 16, 2008 at 5:52 PM, Nicholas T <[EMAIL PROTECTED]> wrote: > hello all, > > A few times in practice I have been tripped up by how Python keeps > variables in scope after a loop--and it wasn't immediately obvious what the > problem was. I think it is one of the ugliest and non-intuitive features, > and hope some others agree that it should be changed in py3k. > > >>> for a in range(11): pass > ... > >>> print(a) > 10 > > Thanks, > Nicholas
_______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com