Some very good points made here. On 1/10/07, Josiah Carlson <[EMAIL PROTECTED]> wrote: > Yeah, I like reusing the variable names bound in a for loop. And unless > we are going to attempt to simplify the <assignment target> in... > > for <assignment target> in ...: > ... > > to only be a bare name, and not things like 'i, (j, k)', then removing > names is going to be difficult. I would be -1 on any changes to the for > loop syntax (value unpacking is so darn convenient), and without syntax > change, then variable bleeding semantics would be difficult to change > (which I am also -1 on).
I had overlooked that. Good point on the complications of unpacking. Just like for loops, though, there are probably cases where looking at a leaked 'with x as y' variable is as useful. Say you're trying to do an atomic database operation, wrapped in 'with db as cursor'. You want the transactional behavior inside the structure, but afterwards you might want to do some read operations to the database. Could be 'cursor' I'm not saying I think that sort of code is a good idea, but if "accessing leaked variables is convenient" is an argument to keep for-loop behavior, perhaps it's an argument for keeping with-statement behavior as well. (Even if you don't like my example, who knows what sorts of things people will do with context managers?) On 1/10/07, Jim Jewett <[EMAIL PROTECTED]> wrote: > So re.use_resource() will usually work (as it does today). > > The difference is that when it doesn't work, you'll see something > about NoneType instead the exception type. Actually, the problem won't be NoneType, it'll be an UnboundLocalError, which could be confusing. ("what do you mean, unbound? I assigned it right there.") But the point that my code sample was already broken is well taken. A warning would be mildly nice to have, but this transformation won't introduce new bugs like I initially thought. Thanks, Greg F _______________________________________________ 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