+ 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 Festus Ajayi
Segun Festus Ajayi - avatar
1 Respuesta
+ 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