private attribute changeage bob sue sue private attribute fetchage private attribute changeage :\codepy - - access-test py suppresses the four access error messages here' generalized argument validator for you to study on your own it uses passed-in validation functionto which it passes the test' criteria value coded for the argument in the decorator this handles rangestype testsvalue testersand almost anything else you can dream up in an expressive language like python 've also refactored the code bit to remove some redundancyand automated test failure processing see this module' self-test for usage examples and expected output per this example' caveats described earlierthis decorator doesn' fully work in nested mode as is--only the most deeply nested validation is run for positional arguments--but its arbitrary valuetest can be used to combine differing types of tests in single decoration (though the amount of code needed in this mode may negate much of its benefits over simple assert!""file argtest py( xfunction decorator that performs arbitrary passed-in validations for arguments passed to any function method range and type tests are two example usesvaluetest handles more arbitrary tests on an argument' value arguments are specified by keyword to the decorator in the actual callarguments may be passed by position or keywordand defaults may be omitted see self-test code below for example use cases caveatsdoesn' fully support nesting because call proxy args differdoesn' validate extra args passed to decoratee' *argsand may be no easier than an assert except for canned use cases ""trace false def rangetest(**argchecks)return argtest(argcheckslambda argvalsarg vals[ ]def typetest(**argchecks)return argtest(argcheckslambda argtypenot isinstance(argtype)def valuetest(**argchecks)return argtest(argcheckslambda argtesternot tester(arg)def argtest(argchecksfailif)def ondecorator(func)if not __debug__ decorators validate args per failif criteria oncall retains funcargchecksfailif no-op if "python - main py args