Bug in __init__?

Bart Ogryczak B.Ogryczak at addr.in.reply-to.invalid
Sun Jan 20 16:39:35 CET 2008


On 2008-01-18, citizen Zbigniew Braniecki testified:
> It's really a nice pitfall, I can hardly imagine anyone expecting this, 

AFAIR, it's described in Diving Into Python.
It's quiet elegant way of creating cache.

def calculate(x,_cache={}):
	try:
		return _cache[x]
	except KeyError:
		_cache[x] = result = _lotsa_slow_calculations(x)
		return result

bart
-- 
            This signature is intentionally left blank.
http://candajon.azorragarse.info/ http://azorragarse.candajon.info/



More information about the Python-list mailing list