On 12/05/2013 10:20 AM, Allen Li wrote:
90% of the time, it ends up looking something like this:
class Foo(metaclass=abc.ABCMeta):
@abc.abstractmethod
def f1(self):
raise NotImplementedError
@staticmethod
@abc.abstractmethod
def f2(arg1):
raise NotImplementedError
I think we're getting sidetracked by the `raise NotImplementedError` -- why do you have that line in there? If I
understand the ABCs correctly a class that does *not* have concrete methods to replace the abstract methods will raise
an exception at class creation time, so why do you need the `raise NotImplementedError`? It would only ever happen on a
super() type of call.
Having said all that, I would hope that any abstract class I had to implement would have good doc strings, and the
multi-line format is much easier to read.
-1 on the one-liner.
--
~Ethan~
_______________________________________________
Python-Dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com