True Statements About Decorators

Select all that apply.

def logged(func):
    def wrapper(*args, **kwargs):
        print(f"calling {func.__name__}")
        return func(*args, **kwargs)
    return wrapper

@logged
def add(a, b):
    """Add two numbers."""
    return a + b
A

If some other module does import this_module twice, this module's top-level code, including the @logged def add line, runs again on the second import.

B

The @logged line runs logged(add) once, immediately when this module is loaded, not later when add(...) is called.

C

Calling add(2, 3) twice re-invokes logged once per call, rebuilding a fresh wrapper from scratch each time.

D

add.__doc__ is None, not "Add two numbers.", because wrapper carries no docstring of its own and nothing copies the original one onto it.