Den lördag 11 april 2015 kl. 17:26:03 UTC+2 skrev Steven D'Aprano: > On Sun, 12 Apr 2015 01:00 am, jonas.thornv...@gmail.com wrote: > > > If two functions crossreference eachother back and forth what happen with > > the local variables. > > Nothing. They are local to the function that creates them. > > > > Will there be a new instance of function holding the variables or do they > > get messed up? > > No to both of those. You have two functions, each with it's own locals. > > > def spam(): > colour = "red" > print("Inside spam: colour is:", colour) > eggs() > print("Inside spam after calling eggs: colour is:", colour) > eggs() > > > def eggs(): > colour = "yellow" > print("Inside eggs: colour is:", colour) > > > Calling spam() gives you this output: > > py> spam() > Inside spam: colour is: red > Inside eggs: colour is: yellow > Inside spam after calling eggs: colour is: red > Inside eggs: colour is: yellow > > > Even if the functions call each other (mutual recursion) each function's > local variables remain local. > > > > -- > Steven
I don't think it matter butt eggs also calls spam, once more. -- https://mail.python.org/mailman/listinfo/python-list