Aug-27-2017, 09:21 PM
I should clarify that.
My intention was to encapsulate the cache. You can do the trick inside the function definition. I think the most people don't know, that mutable objects are created at function definition time. This is odd.
The easiest way is, to define the cache-dictionary outside of the function and call it explicit with the function.
My intention was to encapsulate the cache. You can do the trick inside the function definition. I think the most people don't know, that mutable objects are created at function definition time. This is odd.
The easiest way is, to define the cache-dictionary outside of the function and call it explicit with the function.
# instead of def foo(cache={}): # code # explicit def foo(cache): # codeAlternatives can be a class or a closure. But for a class the function is too minimal.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!