On 12/05/2013 12:39 PM, MRAB wrote:
On 05/12/2013 19:22, Ethan Furman wrote:
On 12/05/2013 10:56 AM, Alexander Belopolsky wrote:
On Thu, Dec 5, 2013 at 1:24 PM, Guido van Rossum wrote:

How would you get the docstrings in? [...]

One way to reduce the amount of boilerplate code is to make abstractmethod
to supply raise NotImplementedError body when none is given.  Then you can
 write

class Foo:
     @abc.abstractmethod
     def do_bar(self):
          """perform bar"""

The docstring will be required when skipping the body which is probably a good 
thing.

How will abstractmethod know its function has no body?

An abstract method won't have a body (I'm not counting the docstring).

If it _does_ have a body, then it's _not_ an abstract method!

To quote the docs [1]:

Note

Unlike Java abstract methods, these abstract methods may have an implementation.
 This implementation can be called via the super() mechanism from the class that
 overrides it. This could be useful as an end-point for a super-call in a 
framework
 that uses cooperative multiple-inheritance.

--
~Ethan~

[1] http://docs.python.org/dev/library/abc.html
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to