Hi Wolfgang,

thanks for your kind reply. I try to explain what I got from your reply:

for code1, when running "foo = outer()", since outer() is callable, function 
outer() is running and it returns an object, which referring to function 
inner(). When "foo" is running, it indicates it is referring to object inner(). 
When "foo()" is running, object inner() is called, so it prints "inside inner".

for code2, when running "foo = outer()", since outer() is callable, function 
outer() is running and returns results from function inner(), which prints 
"inside inner". so "foo" now is a string, which contains "inside inner". since 
this string isn't a function, foo() will make an error.

Do you think my understanding is right? thanks.


regards
skyworld chen

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to