X = 11 # My X: global to this file only import moda # Gain access to names in moda moda.f() # Sets moda.X, not this file's X print(X, moda.X)
#!/usr/bin/env python # coding: utf-8 X = 11 import moda moda.f() print X, moda.X
X = 11 # my X: global to this file only import moda # gain access to names in moda moda.f() # sets moda.X, not my X print X, moda.X
X = 11 # 내 X: 이 파일에서만 전역 import moda # moda의 이름들에 대한 접근 권한을 갖게 됨 moda.f() # 이 파일의 X가 아니라 moda.X를 설정 print(X, moda.X) # pythonb modb.py # 11 99
X = 11 print X from moda import X, f f() print X
x = 11 # meu x: global apenas para esse arquivo import moda # obtem acesso aos nomes presentes em moda moda.f() # configura moda.x e não meu x print(x) # 11 print(moda.x) # 99
#!/usr/bin/env python3 #encoding=utf-8 #------------------------------------------------------- # Usage: python3 modb.py # Description: module basic and scope #------------------------------------------------------- x = 11 # x, global to this file only import moda # Gain access to names in moda moda.f() # Sets moda.x, not this file's x print(x, moda.x) # print 11 99