I am comfused about the name behavior of Python in recursion

380162267qq at gmail.com 380162267qq at gmail.com
Wed Oct 5 20:30:22 EDT 2016


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 10....1 normally.Why it works? Because of the stack memory management?

Thank you



More information about the Python-list mailing list