
June 13, 2011
12:22 p.m.
On 13 June 2011 12:57, Nick Coghlan <ncoghlan@gmail.com> wrote:
As yet another shade for this particular bikeshed, this one just occurred to me:
def do_and_remember(val, verbose=False): @def mem=collections.Counter() result = do_something(val) mem[val] += 1 if verbose: print('Done {} times for {!r}'.format(_mem[val], val))
Or to link this to PEP 3150: given: mem = collections.Counter() def do_and_remember(val, verbose=False): result = do_something(val) mem[val] += 1 if verbose: print('Done {} times for {!r}'.format(_mem[val], val)) (Or the other way around) -- Arnaud