[Tutor] defining functions.. why return?

Frank Holmes flash1210@hotmail.com
Wed, 05 Dec 2001 23:09:58 -0800


   I am working my way thru "SAMS teach yourself Python in 24 hrs by Van 
Laningham (funny, it seems to be taking me a lot more than 24 hrs...) and I 
have a question  concerning defining functions.
   In his example (chapter 7 "functions and modules) Mr. Van Lanningham 
shows the following example for defining a function:

1.  def julian_leap (y):
2.  if (y%4)==0:
3.     return 1
4.  return 0

   Concerning the "return" statements, he says the interpreter keeps track 
of the place where the function was called and the return statement just 
means "goto the place in the code that you started from".
   I don't understand... The example gives 2 "return" statements... where 
are they "goto  ing"?
   I used the example function in a form:

for x in years: [1900, 1040, 1968, 1955]
    if julian_leap (x):
          print"1"
    else:
          print "2"

   it seemed to work regardless of whether I used both returns, or either, 
or none at all. So why the "return 1 and return 0 statements?

                                             thanx

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp