[New-bugs-announce] [issue5867] No way to create an abstract classmethod

Matteo Dell'Amico report at bugs.python.org
Tue Apr 28 16:24:12 CEST 2009


New submission from Matteo Dell'Amico <della at linux.it>:

Is there a way to define an abstract classmethod? The two obvious ways
don't seem to work properly.

Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import abc
>>> class C(metaclass=abc.ABCMeta):
...     @abc.abstractmethod
...     @classmethod
...     def f(cls): print(42)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 3, in C
  File "/usr/lib/python3.0/abc.py", line 24, in abstractmethod
    funcobj.__isabstractmethod__ = True
AttributeError: 'classmethod' object has no attribute '__isabstractmethod__'
>>> class C(metaclass=abc.ABCMeta):
...     @classmethod
...     @abc.abstractmethod
...     def f(cls): print(42)
... 
>>> class D(C): pass
... 
>>> D.f()
42

----------
components: Library (Lib)
messages: 86744
nosy: della
severity: normal
status: open
title: No way to create an abstract classmethod
type: behavior
versions: Python 3.0

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5867>
_______________________________________


More information about the New-bugs-announce mailing list