vendredi 19 décembre 2014

How do I call a Python function that returns a boolean from within an if-statement?

Using Python 3.4. Trying to maintain a functional style and have attempted to call a function that returns a boolean--always either True or False--from within an IF-statement. The function is expensive to run, so I want to call it only when I know it is needed, hence calling from within a decision point. The reference manual syntax disallows what I'm trying to do within the IF condition, so I tried it within the ELSE block. That didn't work because the boolean return isn't reliably seen within the ELSE. Surely this is a common problem for which there is a solution. I just need help finding it.


Aucun commentaire:

Enregistrer un commentaire