看到一篇为文章讲的不错,主要顺序是:
- Evaluate operator
- Evaluate operand(s)
- Apply operator to operands
a. Create a new frame
b. Create arguments as local variables
c. Execute the body of the function
这也解释了我第一篇文章中为什么不能用if_function替代 if else statement的问题
def if_function(c,t,f):
if c:
return t
else:
return f
链接在此,里面有一些细节的问题如parent environment等
environment diagram笔记