What doe ir mean in this context?

from functools import wraps
def debug(func):
    """Print the function signature and return value"""
    @wraps(func)
    def wrapper_debug(*args, **kwargs):
        args_repr = [repr(a) for a in args]
        kwargs_repr = [f"{k} = {v!r}" for k, v in kwargs.items()]
        singature = ", ".join(args_repr + kwargs_repr)
        print(f"Calling {func.__name__}({singature})")
         value = func(*args, **kwargs)
         print(f"{func.__name__!r} returned {value!r}")
         return value
     return wrapper_debug


@debug
def make_greeting(name, age=None):
     if age is None:
         return f"Howdy {name}!"
     else:
         return f"Whoa {name}! {age} already, you are growing up!"

make_greeting(“Benjamin”)

quesion: what does (!r) mean? any further links?

Line 7 and line 8 for me it’s not easy to understand.

You want to read up on this:

It’s an explicity conversion flag. You add !r after v and it will print it out a special way.

2 Likes