@@ -540,6 +540,40 @@ Glossary
540540Exercises
541541---------
542542
543+ Obtain the `skeleton code for these exercises from GitHub classroom
544+ <> `__.
545+
546+ .. proof :exercise ::
547+
548+ The objective of this exercise is to write a :term: `decorator ` which logs
549+ whenever the decorated function is called. This sort of decorator could be
550+ very useful in debugging code. Create the decorator in the
551+ `log_decorator.log_decorator ` module and ensure it is importable as
552+ `log_decorator.log_call `. The decorator should be applicable to functions
553+ taking any combination of arguments.
554+
555+ The logging itself should be accomplished using
556+ the built-in `logging ` module by calling :func: `logging.info ` and passing
557+ the logging message.
558+
559+ The logging message should comprise the function name (accessible using the
560+ `__name__ ` attribute), followed by round brackets containing first the
561+ :func: `repr ` of the positional arguments, followed by the key=value pairs
562+ the keyword arguments.
563+
564+ .. proof :exercise ::
565+
566+ The :mod: `groups.groups ` module in the skeleton code is the new version
567+ introduced above, using an :term: `abstract base class `. The
568+ `log_decorator.log_call ` :term: `decorator ` has been applied to the
569+ :math: `Group._validate` :term: `abstract method `. However, even once you
570+ have implemented this decorator, it never gets called. Your challenge is to
571+ modify :mod: `groups.groups ` so that the decorator is called every time a
572+ subclass :meth: `_validate ` method is called, but **without ** moving or
573+ duplicating `@log_call `.
574+
575+
576+
543577Exam preparation
544578----------------
545579
0 commit comments