I like that loop variables end up still in scope, as demonstrated so far on this list it is quite useful, but only when there is a break somewhere. The one that confuses me, therefore, is the dummy variables in a generator expression leaking into the scope defining that expression. Hence:
x = 0 L = [f(x) for x in range(2)] assert x == 1 This is not particularly intuitive as the for loop in a generator expression can never break; generator expressions feel more "closed". Richard. On Fri, Apr 18, 2008 at 2:15 PM, Facundo Batista <[EMAIL PROTECTED]> wrote: > 2008/4/18, Nicholas T <[EMAIL PROTECTED]>: > > > > Amaury - I think it's generally cleaner code to write > > for myObject in someList: > > if myObject.fits(): > > process(myObject) > > break > > than > > for myObject in someList: > > if myObject.fits(): > > break > > process(myObject) > > See, I do this a lot: > > for a, b, c in someList: > if <some condition with a or b>: > break > else: > c = foobar > c.something() > > Regards, > > -- > . Facundo > > Blog: http://www.taniquetil.com.ar/plog/ > PyAr: http://www.python.org/ar/ > > > _______________________________________________ > 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/r.w.thomas.02%40cantab.net > _______________________________________________ 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