[Python-Dev] One-line abstractmethod function?

Gregory Salvan apieum at gmail.com
Fri Dec 6 07:28:57 CET 2013

maybe a syntax like that can correspond:

class MyObject(metaclass=ObjectSpec):
    ''' MyObject doc'''
    'attr1 contains something'
    attr1 = None
    'attr2 contains something'
    attr2 = str
    'method1 do something'
    method1 = NotImplementedMethod('self', 'arg1', kwarg1=str)

Metaclass "ObjectSpec" would extend ABCMeta to search class source code for
comments before members assignement,
and replace NotImplementedMethod objects by a corresponding method wich
signature can simply be given by arguments or by ArgSpec, FullArgSpec,
with factories like these of "Signature" (from_function, from_builtins...).

2013/12/6 Guido van Rossum <guido at python.org>

> On Thu, Dec 5, 2013 at 6:31 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> >> On Thu, Dec 05, 2013 at 01:33:00PM -0800, Guido van Rossum wrote:
> >>> Actually if you want to support multiple inheritance of your ABC, your
> >>> abstract methods *must* be no-ops (or have some kind of default
> >>> behavior that can always be done last).
> > Done last or first really depends on what the default behavior is,
> doesn't
> > it?  Using __new__ as an example, the chain of calls for that has the
> most
> > ancestorish (yeah, I just made that word up ;) method doing the work
> first,
> > with each less-ancestorish method building on to that as the call chain
> > unwinds.
> If you count which call *starts* first, the base class is always
> called later than the subclass (even if it finishes earlier :-).
> --
> --Guido van Rossum (python.org/~guido)
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/apieum%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131206/d6477540/attachment.html>

More information about the Python-Dev mailing list