mercredi 11 mai 2022

Python Adapter pattern class takes no arguments error

I am learning the Adapter pattern using a straightforward example, I am facing a TypeError: ElfAdapter() takes no arguments when I am trying to add Class as an argument. WHY...? any ideas?

class Elf:
    def null_nin(self):
        print('Elfs says: calling the overlord ...')

class ElfAdapter:
    def __int__(self, elf):
        self.elf = elf

    def call_me(self):
        self.elf.null_nin()

if __name__ == '__main__':
    minions = [ElfAdapter(Elf())]

    for minion in minions:
        minion.call_me()

Aucun commentaire:

Enregistrer un commentaire