Skip to main content
Background Image
  1. Posts/

Python Decorators With Function and Decorator Parameters

·1 min·
Yalchin Mammadli
Author
Yalchin Mammadli
Experienced Python developer with 6+ years of expertise in Django, Flask, and FastAPI, specializing in high-performance web applications. Skilled in Node.js/TypeScript (Express), Docker, CI/CD, and TDD with 95% test coverage. Proven track record across ERP, CRM, e-commerce, blockchain, and AI projects. Focused on continuous growth and delivering impactful, scalable solutions.
def modify_multiply_decorator(*args, **kwargs): # coeff=3

	def dec(multiply_func):

		def inner(*nums): # (2, 290)
			coefficient = kwargs["coefficient"] # 3
			result = multiply_func(*nums) # 2 * 290
			modified_result = coefficient * result # 3 * 580

			return modified_result # 1740

		return inner

	return dec
@modify_multiply_decorator(coefficient=3)
def multiply(*nums):

	return nums[0] * nums[1]

print(multiply(2,290))

Related

How to Setup Mailgun in Django
·3 mins
Accent and Case Insensitive Search and Minimum Distance Calculator in Pymongo
·4 mins
How to Setup Github Ssh Key
·2 mins
How to Deploy Nodejs App
·3 mins
Securely Configure Vps
·5 mins