Return Statement

Stephen Hansen me+list/python at ixokai.io
Wed Jan 26 16:33:15 EST 2011


On 1/26/11 12:26 PM, sl33k_ wrote:
> How does "return True" and "return False" affect the execution of the
> calling function?

It doesn't -- the value 'True' or 'False' is simply returned, and
assigned to a name if the calling function does so explicitly. But
there's no built in affects. If you want it to alter the execution, you
have to do so yourself, i.e.:

def myfun():
    return True
def myfun2():
    return False

if myfun():
    print "Something is true!"

myfun2()
print "I'm called. Cuz, the return value of myfun2 was simply discarded."

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20110126/25d8d81e/attachment.sig>


More information about the Python-list mailing list