0
decorator function
I have written a code dec.fail3.py And can't understand why it's not running def decor(func) : def wrap () : print("???????????????????") func() print("???????????????????") return wrap def mysteries_func: print("mysteries") decoration = decor (mysteries_func) decoration () The code playground said there was an error with decoration () I'd put it in the format in the example but it doesn't work because of the last line? I'm lost here
8 ответов
+ 2
def decor (func):
def wrap():
print ("?????????????????????")
func()
print("???????????????????")
return wrap
def mysteries_func():
print("mysteries of the universe")
decorator=decor(mysteries_func)
decorator()
+ 1
It should be decoration() not decoration=()
Also def decor():
not def decor:
+ 1
Oh you need to pass function you want to decorate to decorator function as well
So it should be def decor(func):
+ 1
It's best if you upload your code in Code Playground and link it here.
That way, we can be sure there are no formatting errors or anything that get lost when you copypaste.
Also it makes testing your code easier for anyone who's going to help you.
0
I'll try but the problem seems to. Be with decorated () holding no value
0
Yes I had put it in as that and as decorator(). The above code has been edited to what I put, sorry about that
0
So I did that and it's still not running
0
Still not working for me? What have I done wrong? I'll take another loook