正在加载图片...
Local Names Variable Lookup: Lookup name in the current frame 。 Lookup name in parent frame,its parent frame,etc.. Stop at the global frame If not found,an error is thrown Global frame >func f(x.y)[parent=Global] An error is thrown func g(z)[parent=Global] g f1:f【parent=Global] def f(x,y): Name"x"is not found,again ×5 y10 return g(x) Name"x"is not found 2 8 parent=Global] z5 def g(z): Important:There was no lookup done in f1 since return z x the parent of f2 was Global What happens here? result f(5,10)Where do we look next? Local Names Variable Lookup: • Lookup name in the current frame • Lookup name in parent frame, its parent frame, etc.. • Stop at the global frame • If not found, an error is thrown def f(x, y): return g(x) def g(z): return z + x result = f(5, 10) Name “x” is not found Name “x” is not found, again An error is thrown What happens here? Important: There was no lookup done in f1 since the parent of f2 was Global
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有