Which fix removes the bug?
class Cache:
store = {}
def put(self, k, v):
self.store[k] = v
- Create store in __init__
- Copy store on each put
- Mark store as private
- Use a classmethod here
A class attribute is shared by every instance, so all caches see each other's entries.
Play Problem Solving ▸