我無法從另一個類別調用方法。我得到錯誤,因爲請求沒有被定義,而調用方法。根據討論,我試圖從另一個類像get_user(request)調用方法。並試圖從另一個類訪問變量從另一個類別調用變量的方法問題
class A(object):
def get_user(self,request):
a = self.request.get_full_path()
class B(A, AllowEmptyMixin, AutoModelSelect2Field):
b = A()
b.get_user(request) ---->>> Getting error "request" is not defined
任何人都清楚我的問題
你期望傳遞給'get_user()'什麼? – zondo
@PythonTeam看到你的[python上的其他問題]後(http://stackoverflow.com/questions/35792644/cant-able-to-get-current-url-in-python)。我的意思是沒有不尊重,但你可能想考慮檢查python教程的基礎知識。你正在編寫的代碼並沒有形成太多的邏輯意義。 – castis
爲什麼你會再次提出[同樣的問題](http://stackoverflow.com/questions/35792644/cant-able-to-get-current-url-in-python)? – AKS