as we also learnedclass decorators can be used to manage classes themselvesrather than just their instances because this functionality overlaps with metaclasses--the topic of the next and final technical you'll have to read ahead for the conclusion to this storyand that of this book at large firstthoughlet' work through the following quiz because this was mostly focused on its examplesits quiz will ask you to modify some of its code in order to review you can find the original versionscode in the book' examples package (see the preface for access pointersif you're pressed for timestudy the modifications listed in the answers instead--programming is as much about reading code as writing it test your knowledgequiz method decoratorsas mentioned in one of this notesthe timerdeco py module' timer function decorator with decorator arguments that we wrote in the section "adding decorator argumentson page can be applied only to simple functionsbecause it uses nested class with __call__ operator overloading method to catch calls this structure does not work for class' methods because the decorator instance is passed to selfnot the subject class instance rewrite this decorator so that it can be applied to both simple functions and methods in classesand test it on both functions and methods (hintsee the section "class blunders idecorating methodson page for pointers note that you will probably need to use function object attributes to keep track of total timesince you won' have nested class for state retention and can' access nonlocals from outside the decorator code as an added bonusthis makes your decorator usable on both python and class decoratorsthe public/private class decorators we wrote in module access py in this first case study example will add performance costs to every attribute fetch in decorated class although we could simply delete the decoration line to gain speedwe could also augment the decorator itself to check the __debug__ switch and perform no wrapping at all when the - python flag is passed on the command line--just as we did for the argument range-test decorators that waywe can speed our program without changing its sourcevia command-line arguments (python - main py while we're at itwe could also use one of the mix-in superclass techniques we studied to catch few built-in operations in python too code and test these two extensions generalized argument validationsthe function and method decorator we wrote in rangetest py checks that passed arguments are in valid rangebut we also saw that the same pattern could apply to similar goals such as argument type testingand possibly more generalize the range tester so that its single code base can be used for multiple argument validations passed-in functions may be the simplest decorators