Форум сайта python.su
Проясните, пожалуйста. Есть класс ConnectionObject, унаследованный от класса Connection.
class ConnectionObject(Connection):
def authenticateWithPassword(self):
super(ConnectionObject, self).authenticateWithPassword(self.username, self.password)
def __init__(self, username, password):
super(ConnectionObject, self).__init__()
self.username = username
self.password = password
con = ConnectionObject(username, password)
con.authenticateWithPassword()
File “D:\developing\ide\projects\netbeans\jython\SshTest\src\sshhelper.py”, line 45, in get_connectionТ.е. такое впечатление, что ConnectionObject вызовом super(ConnectionObject, self).authenticateWithPassword(self.username, self.password) обращается к самому себе. Если заменить эту строку на
con.authenticateWithPassword()
File “D:\developing\ide\projects\netbeans\jython\SshTest\src\sshhelper.py”, line 16, in authenticateWithPassword
super(ConnectionObject, self).authenticateWithPassword(self.username, self.password)
TypeError: authenticateWithPassword() takes exactly 1 argument (3 given)
Connection.authenticateWithPassword(self, self.username, self.password)
Офлайн
Кажется нашел.
http://fuhm.net/super-harmful/
Это ужасно :)
Офлайн
Это ужасно - при наследовании перекрывать виртуальные функции другими, с измененной сигнатурой
Офлайн
Да, пожалуй :) Заведу другой метод.
Офлайн