Bug hunt

Keep the Name

A wrapper replaces the original function, so by default the decorated function forgets who it was: its __name__ becomes "wrapper" and its docstring disappears. That breaks help(), debuggers, logs and tools that look functions up by name.

The fix is one line from functools:

import functools

def announce(func):
    @functools.wraps(func)        # copy name, doc, etc.
    def wrapper(*args, **kwargs):
        return func(*args, **kwargs)
    return wrapper

functools.wraps copies __name__, __doc__, __module__ and more onto the wrapper, and sets wrapper.__wrapped__ to the original function. Always use it in real decorators.

The bug

The guild's @logged decorator is supposed to print -> brew and then behave exactly like brew. Instead the program prints:

-> brew
None
wrapper - None

Assignment

Fix logged so that brew returns its result and keeps its own name and docstring. (Don't change brew itself.)