The answer is D.
if you run this code to decorator a new function, you will get name error, regardless the colon in line 3 is missing or not.
NameError: name 'level2_warpper' is not defined.
This is because our_function (line 4) and my_function(line 2) did not return the SAME function name.
line 2: def level1_wrapper(my_function)
line4: return our_function
To make this code correct, you can make FUNCTION_NAME in line 2 and line 4 consistency. eg. line 4 should be ' return my_function'
B is Wrong. Because we did not have two more decorators for decorator stacking.
C is Wrong. Because the decorator returns arguments 2 times (2 level wrap), not infinite recursion.
A is NOT the answer since the code is wrong. A could be a correct answer if the code is consistency.
my_func('smallcoat','middlecoat')
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
pgcool
8 months, 2 weeks agoMoneybing
1 year agofabian123324
1 year, 2 months agorafles
1 year, 3 months ago