memoize def func print calculating return func calculating func calcul

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
>>> @memoize
def func(a, b):
print "calculating %s + %s" % (a, b)
return a + b
>>> func(1, 5)
calculating 1 + 5
<<< 6
>>> func(2, 5)
calculating 2 + 5
<<< 7
>>> func(2, 5)
<<< 7