I have two questions
- how can I docstring a argument that is a function
- is it a good idea to use lambda when I have couple line of code like
print('xxxx')but i need the same function (time.sleep(5)) to be executed between them
#method 1
time.sleep(5)
print('i am first')
time.sleep(5)
print('i am 2nd')
time.sleep(5)
print('i am 3rd')
time.sleep(5)
print('i am 4th')
time.sleep(5)
print('i am 5th')
#method 2
import time
def add_delay_between_action(func):
time.sleep(5)
func()
time.sleep(5)
add_delay_between_action(lambda: print('i am first'))
add_delay_between_action(lambda: print('i am 2nd'))
add_delay_between_action(lambda: print('i am 3rd'))
add_delay_between_action(lambda: print('i am 4th'))
add_delay_between_action(lambda: print('i am 5th'))
time.sleepinadd_delay_between_action, otherwise you're sleeping both after one function and before the next, which will add up to 10 seconds between functions instead of 5.add_delay_between_actionshould probably be renamed toadd_delay_after_action