def my_test(some_function):
def wrapper():
num = 10
if num == 10:
print("Yes")
else:
print("No")
some_function()
print("Something is happening after some_function() is called")
return wrapper
def just_some_function():
print("Filler text")
my_test(just_some_function)
When I run this script, it should display:
Yes
Filler text
Something is happening after some_function() is called
since my_test(just_some_function)
calls my_test
, goes through the wrapper function, checks if num == 10
, prints "Yes," then goes to just_some_function()
(since some_function
is the "variable" for the function my_test()
), prints "Filler text," then finally ends by printing "Something is happening after some_function() is called." But nothing happens in the console when I run the script.