0
這是在Python 2.7.3完成:導入變量賦予屬性的python錯誤
x.py:
import y
global path_variable
path_variable = "a_path"
y.procedure()
y.py:
import x
def procedure():
return x.path_variable
現在,當我運行XI得到這個奇怪的錯誤:
AttributeError: 'module' object has no attribute 'path_variable'
這是爲什麼?據我所知python允許你導入變量。難道我做錯了什麼?
這不是全部代碼。所以x是全球性的。我只是想我會說這是全球性的,也看看它是否會有所作爲。 – madprogramer 2013-04-05 13:52:46