This is where am getting error messages every time. my answer here is @my_dec | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

This is where am getting error messages every time. my answer here is @my_dec

Which statement can be used to achieve the same behavior as my_func = my_dec(my_func)? @my_dec my_func = @my_dec my_dec(my_func)

13th May 2024, 1:43 PM
Segun Ajayi
Segun Ajayi - avatar
1 Answer
+ 2
Here, my_func = @my_dec, this syntax is not valid in Python. You cannot directly assign a decorator to a function in this manner. Also, my_dec(my_func), this line directly calls the decorator my_dec with my_func as an argument, which is not how decorators are typically used. You can write as follows: @my_dec def my_func(): pass
13th May 2024, 2:28 PM
`нттየ⁴⁰⁶
`нттየ⁴⁰⁶ - avatar