Dear List,

the following comes from Harrington's "Hands-on Python" (section 1.11.8): http://www.cs.luc.edu/~anh/python/hands-on/


<code>

'''Avoiding any error by passing a parameter'''

def main():
    x = 3
    f(x)

def f(whatever):
    print whatever

main()

</code>

I am not quite sure what is going on here. Could you please correct my line of thought?

1) main() calls the function def main():

2) in function def main(): the actual parameter 3 is given to the function call f().

3) f() then "jumps" out of function def main(): to call function
def f(whatever):, whose new value, 3, gets printed.

Is this what is going on? I find it difficult to get my head around this one. Also: does Python go back to the function call main()'s position after step 3)? How does that work? Again via def main():???

Cheers for any clarifications,

David
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to