Created
September 19, 2012 00:05
-
-
Save civic/3746850 to your computer and use it in GitHub Desktop.
How does it work? func1 and func2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pythonのスコープは分かりにくい例。
このコードの実行結果はfunc1(), func2()でそれぞれどうなるか?
答えはこちら。 https://gist.github.com/3747391