Pierre Barbier de Reuille wrote:
> Even if iterator-for-loops can be used within a block without damage, 
> the use of iterator-for-block in a loop can lead to completely 
> unpredictable result (and result really hard to find since they'll 
> possibly involve race conditions or dead locks).

I had a longish post written before I realised I'd completely misunderstood 
your 
comment. You were actually agreeing with me, so most of my post was totally 
beside the point.

Anyway, to summarise the argument in favour of separate API's for iterators and 
block templates, the first code example below is a harmless quirk (albeit an 
irritating violation of TOOWTDI). The second and third examples are potentially 
serious bugs:

   block range(10) as i:
     # Just a silly way to write "for i in range(10)"

   for f in opening(name):
     # When f gets closed is Python implementation dependent

   for lock in synchronized(mylock):
     # When lock gets released is Python implementation dependent

Cheers,
Nick.

P.S. Dear lord, synchronized is an aggravating name for that function. I keep 
wanting to spell it with a second letter 's', like any civilised person ;)

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to