Почему Python не выводит объект 'Wizard', не имеющий атрибутов 'evil' или 'other'?Разве это не должно быть объявлено раньше?
class Wizard:
def __init__(self, mana):
self.mana = mana
def stupor(self, other, harm=50):
# self.other = other }
# self.harm = harm } Shouldn't this be necessary to Python understand
# the code inside if statement?
#
if self.mana >=100:
other.mana -= harm # } this code
tom = Wizard(112)
dumbledore = Wizard(151)
tom.stupor(dumbledore)
dumbledore.stupor(tom,200)
for n in range(0,10):
tom.stupor(dumbledore)
print(tom.mana)
print(dumbledore.mana)
Я ожидаю, что AttributeError: у объекта 'Wizard' нет атрибута 'evil' AttributeError: У объекта 'Wizard' нет атрибута 'other'
Но код работает.Почему?