[Python-Dev] One-line abstractmethod function?
cyberdupo56 at gmail.com
Thu Dec 5 19:20:22 CET 2013
Hello Python devs,
As a regular Python user, I find the abc module useful for making
Python's duck typing more explicit. In particular, I ofen use it
like a Java interface or C header, to provide methods to implement for a
given "duck type".
90% of the time, it ends up looking something like this:
What if there was a function, say make_abstract_method (better name
pending), so that the above could be written like:
f1 = abc.make_abstract_method('f1', ['self'])
f2 = staticmethod(abc.make_abstract_method('f2', ['arg1']))
I think that it would make ABC definitions a lot more compact for many
use cases, but I welcome any criticisms against this idea.
More information about the Python-Dev