Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
437 B
1
Indexable
Never
# code for testing decorator chaining
def decor1(func):
	def inner(*args, **kwargs):
		x = func(*args, **kwargs)
		return x * x
	return inner

def decor(func):
	def inner(*args, **kwargs):
		x = func(*args, **kwargs)
		return 2 * x
	return inner

@decor1 # ref: inner de decor -> Inner de decor1
@decor # ref: num -> inner de decor
def num():
	return 10
#cuando es llamado num() llamará al inner de decor1
print(num())