from mymod import * val = 999 def print_val(): print(val) def set_val(num): global val val = num print_val() # => 999 set_val(456) print_val() # => 456 SVOQZ # -*- coding:utf-8 -*- val = 0 NZNPEQZ
global x ^ SyntaxError: name 'x' is used prior to global declaration # -*- coding:utf-8 -*- x = 0 def foo(): x = 10 print(x) global x x = 20 print(x) foo() SFTVMU