我有一个文件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