Python · Decorators

A test suite reuses an @lru_cache'd function across cases and gets stale results carried between tests. What method resets the cache, and what does it take?

Answer locked. Get the free KnowCard app to reveal it — plus spaced-repetition review so it actually sticks.

Get it on App StoreGet it on Google Play

This is one card from the KnowCard library — thousands more across SAP, Linux, Python and more. In the app you get the answer, AI explanations, and cards that come back right before you would forget them. Free to start on iOS, Android or the web.

More in Decorators

What does @deco written above a function definition actually do to the name?
A decorator's wrapper is written as def wrapper(*args, **kwargs): and calls fn(*args, **kwargs). Why both the */** in the signature AND in the call?
What does this print? ```python def with_timing(fn): def wrapper(*a, **k): return fn(*a, **k) return wrapper @with_timing def nap(): """sleep""" print(nap.__name__) ```
What does functools.wraps do, and where do you put it?
What does this print? ```python def a(f): def w(): print("a"); f() return w def b(f): def w(): print("b"); f() return w @a @b def g(): print("g") g() ```
@a then @b above a function is equivalent to which single assignment?

Start learning today

Free to start — download the app or use it in your browser.

Get it on App StoreGet it on Google Play