Skip to content

Instantly share code, notes, and snippets.

@civic
Created September 19, 2012 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save civic/3746850 to your computer and use it in GitHub Desktop.
Save civic/3746850 to your computer and use it in GitHub Desktop.
How does it work? func1 and func2
def main():
x1=1
x2=1
def func1():
y1=x1+10
print 'func1', x1,y1
def func2():
y2=x2+10
x2=2
print 'func2',x2,y2
func1()
func2()
main()
@civic
Copy link
Author

civic commented Sep 19, 2012

Pythonのスコープは分かりにくい例。
このコードの実行結果はfunc1(), func2()でそれぞれどうなるか?
答えはこちら。 https://gist.github.com/3747391

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment