Using a library that when I call a certain function that I will call foo()
, I am prompted for input as such:
def foo():
if input("Proceed?") == 'yes':
take_action()
I am required to pass in an answer to continue.
But I would like to be able to loop over foo()
with a default value to feed the prompt.
The problem is the developers did not provide an option to supply a default value for the prompt.
Ideally they would have written foo()
like this:
def foo(default_response=None):
if default_response == 'yes':
take_action()
elif input("Proceed?") == 'yes':
take_action()
Given that they did not supply an option for a default response, is there a way for me to loop over foo()
and provide the input automatically without changing the source code?