1

I want to create some kind of structure, where the classes that inherit the ABC class can only have the methods that are defined in it and cannot have any other methods in it.

My abc looks like

from abc import ABCMeta, abstractmethod

class Meta(metaclass=ABCMeta):
    @abstractmethod
    async def Foo(self,a:int, b:str):
        raise NotImplementedError

so the classes I make, which inherit this can only have the method Foo and nothing else more.

is this possible to do in python?

random_npc
  • 171
  • 1
  • 12
  • Would manually checking the class' methods work for you? I imagine you could try overriding `__new__` to [check the methods](https://stackoverflow.com/questions/1911281/how-do-i-get-list-of-methods-in-a-python-class) prior instance initialization. – naicolas Jan 26 '21 at 17:37
  • @wankata tysm that worked – random_npc Jan 28 '21 at 14:03

0 Answers0