advanced programming techniques in some cases it would be useful to be able to parameterize decoratorbut at first sight this does not seem possible since decorator takes just one argumenta function or method but there is neat solution to this we can call function with the parameters we want and that returns decorator which can then decorate the function that follows it for example@bounded( def percent(amounttotal)return (amount total herethe bounded(function is called with two argumentsand returns decorator that is used to decorate the percent(function the purpose of the decorator in this case is to guarantee that the number returned is always in the range to inclusive here' the implementation of the bounded(functiondef bounded(minimummaximum)def decorator(function)@functools wraps(functiondef wrapper(*args**kwargs)result function(*args**kwargsif result minimumreturn minimum elif result maximumreturn maximum return result return wrapper return decorator the function creates decorator functionthat itself creates wrapper function the wrapper performs the calculation and returns result that is within the bounded range the decorator(function returns the wrapper(functionand the bounded(function returns the decorator one further point to note is that each time wrapper is created inside the bounded(functionthe particular wrapper uses the minimum and maximum values that were passed to bounded(the last decorator we will create in this subsection is bit more complex it is logging function that records the nameargumentsand result of any function it is used to decorate for example@logged def discounted_price(pricepercentagemake_integer=false)result price (( percentage if not ( result <price)raise valueerror("invalid price"return result if not make_integer else int(round(result)