On 2018-08-14, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > If there really are a lot of such missing methods, I'd consider writing > something like this: > > class A: > def __init__(self, ...): > ... > > # === process abstract methods en masse === > for name in "method_a method_b method_c method_d".split(): > @abstractmethod > def inner(self): > raise NotImplementedError > inner.__name__ = name > # This is okay, writing to locals works inside the class body. > locals()[name] = inner > > del inner, name # Clean up the class namespace.
You have a peculiar idea of "good style"... > although to be honest I'm not sure if that would be enough to stop PyLint > from complaining. No - if you think about it, there's no way Pylint could possibly know that the above class has methods method_a, method_b, etc. It also doesn't like the `del inner, name` because theoretically neither of those names might be defined, if the loop executed zero times. -- https://mail.python.org/mailman/listinfo/python-list