do wish to regulate attribute access in order to eliminate coding mistakesor happen to be soon-to-be-ex- ++-or-java programmermost things are possible with python' operator overloading and introspection tools examplevalidating function arguments as final example of the utility of decoratorsthis section develops function decorator that automatically tests whether arguments passed to function or method are within valid numeric range it' designed to be used during either development or productionand it can be used as template for similar tasks ( argument type testingif you mustbecause this size limits have been broachedthis example' code is largely self-study materialwith limited narrativeas usualbrowse the code for more details the goal in the object-oriented tutorial of we wrote class that gave pay raise to objects representing people based upon passed-in percentageclass persondef giveraise(selfpercent)self pay int(self pay ( percent)therewe noted that if we wanted the code to be robust it would be good idea to check the percentage to make sure it' not too large or too small we could implement such check with either if or assert statements in the method itselfusing inline testsclass persondef giveraise(selfpercent)validate with inline code if percent raise typeerror'percent invalidself pay int(self pay ( percent)class personvalidate with asserts def giveraise(selfpercent)assert percent > and percent < 'percent invalidself pay int(self pay ( percent)howeverthis approach clutters up the method with inline tests that will probably be useful only during development for more complex casesthis can become tedious (imagine trying to inline the code needed to implement the attribute privacy provided by the last section' decoratorperhaps worseif the validation logic ever needs to changethere may be arbitrarily many inline copies to find and update more useful and interesting alternative would be to develop general tool that can perform range tests for us automaticallyfor the arguments of any function or method decorators