Python Forum
The of ( : ) what does it do? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: The of ( : ) what does it do? (/thread-37863.html)

Pages: 1 2


RE: The of ( : ) what does it do? - Frankduc - Jul-31-2022

Another question bothering me for a while:

In geeks example:

# code for testing decorator chaining
def decor1(func):
	def inner():
		x = func()
		return x * x
	return inner

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

@decor1
@decor
def num():
	return 10

print(num())
How do you know def decor(func): will be executed first to get to 400? I cant figure out the sequence of events. I tried with https://pythontutor.com/render.html#mode=display
I just dont get it.

But you are right it is a good writup.


RE: The of ( : ) what does it do? - deanhystad - Aug-01-2022

Order