raise typeerror(errmsgelseassume not passeddefault return func(*pargs**kargsreturn oncall return ondecorator @typetest( =intc=floatdef func(abcd)func typetest)(funcfunc( func('spam' ok triggers exception correctly using function annotations instead of decorator arguments for such decoratoras described in the prior sectionwould make this look even more like type declarations in other languages@typetest def func(aintbcfloatd)func typetest(funcgaspbut we're getting dangerously close to triggering "flag on the playhere as you should have learned in this bookthis particular role is generally bad idea in working codeandmuch like private declarationsis not at all pythonic (and is often symptom of an ex- +programmer' first attempts to use pythontype testing restricts your function to work on specific types onlyinstead of allowing it to operate on any types with compatible interfaces in effectit limits your code and breaks its flexibility on the other handevery rule has exceptionstype checking may come in handy in isolated cases while debugging and when interfacing with code written in more restrictive languagessuch as +stillthis general pattern of argument processing might also be applicable in variety of less controversial roles we might even generalize further by passing in test functionmuch as we did to add public decorations earliera single copy of this sort of code would then suffice for both range and type testingand perhaps other similar goals in factwe will generalize this way in the end-of-quiz coming upso we'll leave this extension as cliffhanger here summary in this we explored decorators--both the function and class varieties as we learneddecorators are way to insert code to be run automatically when function or class is defined when decorator is usedpython rebinds function or class name to the callable object it returns this hook allows us to manage functions and classes themselvesor later calls to them--by adding layer of wrapper logic to catch later callswe can augment both function calls and instance interfaces as we also sawsummary