[Python-Dev] PEP 340 -- loose ends
Nick Coghlan
ncoghlan at gmail.com
Tue May 3 15:07:07 CEST 2005
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 | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-Dev
mailing list