I'm stuck in a simple question that I can't find an answer. If want to call a function in an if statement. This is a function really challenging and it takes a long time to get response, how can I preserve the return value?
I explain the problem with an example:
- function
def recursive:
if .... :
return value
else:
return False
recursive is an hypothetically function that takes a lot of time to generating response, that could be a value or just a simple boolean False.
- main
...
if recursive():
...value? (make something with value return)
other method
...
if recursive():
value = recursive()
This other method will call the function 2 times and it takes too long time.
How can I solve this?
Aucun commentaire:
Enregistrer un commentaire