Message173183
This may be an issue with the interpreter behavior or it may be a documentation issue.
Note: I only selected Python 3.3 as the version, but it probably affects MANY other Python versions.
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import abc
>>> help(abc.abstractclassmethod)
Help on class abstractclassmethod in module abc:
class abstractclassmethod(builtins.classmethod)
| A decorator indicating abstract classmethods.
|
| Similar to abstractmethod.
|
| Usage:
|
| class C(metaclass=ABCMeta):
| @abstractclassmethod
| def my_abstract_classmethod(cls, ...):
| ...
|
| 'abstractclassmethod' is deprecated. Use 'classmethod' with
| 'abstractmethod' instead.
. (et cetra)
.
.
>>> # doesn't work
>>> class Demo(metaclass=abc.ABCMeta):
... @abc.abstractmethod
... @classmethod
... def test(cls):
... pass
...
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
class Demo3(metaclass=abc.ABCMeta):
File "<pyshell#26>", line 3, in Demo3
@classmethod
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/abc.py", line 24, in abstractmethod
funcobj.__isabstractmethod__ = True
AttributeError: attribute '__isabstractmethod__' of 'classmethod' objects is not writable
>>> # DOES work
>>> class Demo2(metaclass=abc.ABCMeta):
... @classmethod
... @abc.abstractmethod
... def test(cls):
... pass
...
>>> Demo2()
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
Demo4()
TypeError: Can't instantiate abstract class Demo2 with abstract methods test
Hopefully this is enough documentation to show what the issues is. If not, just chime in. :-) |
|
Date |
User |
Action |
Args |
2012-10-17 15:41:21 | christopherthemagnificent | set | recipients:
+ christopherthemagnificent, docs@python |
2012-10-17 15:41:21 | christopherthemagnificent | set | messageid: <1350488481.01.0.487550684008.issue16267@psf.upfronthosting.co.za> |
2012-10-17 15:41:20 | christopherthemagnificent | link | issue16267 messages |
2012-10-17 15:41:20 | christopherthemagnificent | create | |
|