Re: I am comfused about the name behavior of Python in recursion

2016-10-06 Thread alister
On Wed, 05 Oct 2016 17:30:22 -0700, 380162267qq wrote: > Google told me Python name is a label attaching to the object. > But in this recursive function,the name 'a' will point to different > number object. > > def rec(a): > a+=1 if a<10: > rec(a) > print(a) > > rec(0)

Re: I am comfused about the name behavior of Python in recursion

2016-10-05 Thread Gregory Ewing
38016226...@gmail.com wrote: def rec(a): a+=1 if a<10: rec(a) print(a) rec(0) gives me 101 normally.Why it works? Because of the stack memory management? Yes. There isn't just one 'a' here, there's a different one each time rec is called. Thank yo

Re: I am comfused about the name behavior of Python in recursion

2016-10-05 Thread Ben Finney
38016226...@gmail.com writes: > Google told me Python name is a label attaching to the object. Well, “Google told me” has no necessary bearing on whether it's true :-) so that's not a good citation to give. If you need to know what Python terminology means, the Python documentation is better.

I am comfused about the name behavior of Python in recursion

2016-10-05 Thread 380162267qq
Google told me Python name is a label attaching to the object. But in this recursive function,the name 'a' will point to different number object. def rec(a): a+=1 if a<10: rec(a) print(a) rec(0) gives me 101 normally.Why it works? Because of the stack