2008年1月24日 星期四

Python local variable and global variable

#!/usr/local/bin/python


# Variable scope

first = 1

def one():
"Double a global variable, return it + 3."
global first
first *= 2
result = first+3
return result

print one.__doc__
print one()
print one()
print one()
print "first now has the value",first
print "result has the value",result

沒有留言: