[Python-Dev] One-line abstractmethod function?

Allen Li cyberdupo56 at gmail.com
Mon Dec 9 20:52:53 CET 2013


I just wanted to sum up this thread of discussion.

Proposal:
A function in abc to provide a default abstract method
implementation.

foo = make_abstractmethod('foo', ['self'])

is the same as

@abc.abstractmethod
def foo(self):
    pass

Details:
Default behavior, if implemented, should probably be empty/pass/return
None.  How to handle docstrings?  Either attribute docstring (a separate
discussion) or a parameter in the function call.

Pros:
Save a lot of lines defining interface-like ABCs, especially in small
scripts without docstrings (bad practice, but I do it often =))

Cons:
Do we need it?


More information about the Python-Dev mailing list