Return Statement
Emile van Sebille
emile at fenx.com
Wed Jan 26 16:41:47 EST 2011
On 1/26/2011 12:26 PM sl33k_ said...
> How does "return True" and "return False" affect the execution of the
> calling function?
That depends on the calling function. It will control what it does next
generally based on the returned value, but it could also simply store
the result.
def isACustomer(custID):
1 return custID in currentCustList
def isActive(custId):
2 return custID in openInvoicesByCustID
for custID in custList:
3 if isACustomer(custID):
4 activeFlag = isActive(custID)
Here, 1 and 2 return True or False depending on the inclusion test.
3 causes the subsequent code block to be executed when True is returned
4 stores True of False in activeFlag for subsequent use.
Emile
More information about the Python-list
mailing list