Skip to content

Instantly share code, notes, and snippets.

def add_item(item, items=None):
if items is None:
items = []
"""
Design an in-memory key–value store with TTL
You are asked to implement a very simple in-memory key–value store for configuration data.
The store supports four operations:
set(key, value, ttl_seconds, now)
get(key, now)
delete(key, now)
class A:
def say(self):
print("A")
class B(A):
def say(self):
print("B")
class debug:
def __init__(self, func):
self.func = func
def __get__(self, instance, owner):
if instance is None:
return self.func
def wrapper(*args, **kwargs):
print(f"Calling {self.func.__name__} of {instance!r}")