Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def makeFun(name, *args):
- exec("""def {}({}): raise NotImplementedError("'{}' is not implemented!")""".format(name, ', '.join(args), name))
- return locals()[name]
- class ABC(type):
- def __init__(cls, name, bases, dct):
- for k, v in cls.__dict__.items():
- if not k.startswith("__") and callable(v):
- setattr(cls, k, makeFun(k, *v.__code__.co_varnames))
- class Class(metaclass=ABC):
- def __init__(self, **kwargs):
- pass
- def shouldFail(self, a, b):
- pass
- a = Class()
- try:
- a.shouldFail(1, 2)
- except NotImplementedError as e:
- print(str(e))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement