我有一個文件notifications.py
和comments.py
。通知的類別爲GetNotifications
,功能getNotifs(arg1, arg2)
。我想調用此方法在我comments.py,所以我做的:調用python方法
from notifications import GetNotifications
然後,我創建類的實例:
getNotifsInstance = GetNotifications()
然後我打電話getNotifs:
notifsDictionary = getNotifsInstance.getNotifs(arg1, arg2)
不過,我發現了錯誤: TypeError: getNotifs() takes at most 2 arguments (3 given)
爲什麼當我只給它2個時,我給它3個參數?
當您調用一個實例的方法時,它總是將自身作爲第一個參數傳遞。 – jamylak 2012-04-17 15:08:10