因此,我環顧四周,閱讀了許多覆蓋TypeError的消息,其中「完全使用X參數,但只給出1」 。我知道self
。我不認爲我有一個問題了解self
。無論如何,我試圖創造一些屬性的類只要我在函數hwaddr
前面有@property
,我得到以下錯誤:TypeError:function())使用@property完全接受X參數(1給出)decorator
Traceback (most recent call last):
File line 24, in <module>
db.hwaddr("aaa", "bbbb")
TypeError: hwaddr() takes exactly 3 arguments (1 given)
這裏是代碼。爲什麼@property
搞砸了我?我把它拿出來,和代碼按預期工作:
#!/usr/bin/env python2.7
class Database:
"""An instance of our Mongo systems database"""
@classmethod
def __init__(self):
pass
@property
def hwaddr(self, host, interface):
results = [ host, interface ]
return results
db = Database()
print db.hwaddr("aaa", "bbbb"
Process finished with exit code 1
有了它走了,輸出是:
File
['aaa', 'bbbb']
Process finished with exit code 0
是的,我現在看到。謝謝。我會接受這個答案。我的困惑是出於吸氣的目的。在這裏,我沒有得到一個對象變量......我也沒有在編寫真正的代碼。 –