Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cea27be8
Kaydet (Commit)
cea27be8
authored
Ara 08, 2012
tarafından
Nick Coghlan
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Close issue #16267: better docs for @abstractmethod composition
üst
8e18fc8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
15 deletions
+47
-15
abc.rst
Doc/library/abc.rst
+44
-15
NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/abc.rst
Dosyayı görüntüle @
cea27be8
...
@@ -208,16 +208,20 @@ The :mod:`abc` module also provides the following decorators:
...
@@ -208,16 +208,20 @@ The :mod:`abc` module also provides the following decorators:
A subclass of the built-in :func:`classmethod`, indicating an abstract
A subclass of the built-in :func:`classmethod`, indicating an abstract
classmethod. Otherwise it is similar to :func:`abstractmethod`.
classmethod. Otherwise it is similar to :func:`abstractmethod`.
Usage::
This special case is deprecated, as the :func:`classmethod` decorator
is now correctly identified as abstract when applied to an abstract
method::
class C(metaclass=ABCMeta):
class C(metaclass=ABCMeta):
@abstractclassmethod
@classmethod
@abstractmethod
def my_abstract_classmethod(cls, ...):
def my_abstract_classmethod(cls, ...):
...
...
.. versionadded:: 3.2
.. versionadded:: 3.2
.. deprecated:: 3.3
.. deprecated:: 3.3
Use :class:`classmethod` with :func:`abstractmethod` instead.
It is now possible to use :class:`classmethod` with
:func:`abstractmethod`, making this decorator redundant.
.. decorator:: abstractstaticmethod(function)
.. decorator:: abstractstaticmethod(function)
...
@@ -225,21 +229,26 @@ The :mod:`abc` module also provides the following decorators:
...
@@ -225,21 +229,26 @@ The :mod:`abc` module also provides the following decorators:
A subclass of the built-in :func:`staticmethod`, indicating an abstract
A subclass of the built-in :func:`staticmethod`, indicating an abstract
staticmethod. Otherwise it is similar to :func:`abstractmethod`.
staticmethod. Otherwise it is similar to :func:`abstractmethod`.
Usage::
This special case is deprecated, as the :func:`staticmethod` decorator
is now correctly identified as abstract when applied to an abstract
method::
class C(metaclass=ABCMeta):
class C(metaclass=ABCMeta):
@abstractstaticmethod
@staticmethod
@abstractmethod
def my_abstract_staticmethod(...):
def my_abstract_staticmethod(...):
...
...
.. versionadded:: 3.2
.. versionadded:: 3.2
.. deprecated:: 3.3
.. deprecated:: 3.3
Use :class:`staticmethod` with :func:`abstractmethod` instead.
It is now possible to use :class:`staticmethod` with
:func:`abstractmethod`, making this decorator redundant.
.. decorator:: abstractproperty(fget=None, fset=None, fdel=None, doc=None)
.. decorator:: abstractproperty(fget=None, fset=None, fdel=None, doc=None)
A subclass of the built-in :func:`property`, indicating an abstract property.
A subclass of the built-in :func:`property`, indicating an abstract
property.
Using this function requires that the class's metaclass is :class:`ABCMeta`
Using this function requires that the class's metaclass is :class:`ABCMeta`
or is derived from it. A class that has a metaclass derived from
or is derived from it. A class that has a metaclass derived from
...
@@ -247,23 +256,43 @@ The :mod:`abc` module also provides the following decorators:
...
@@ -247,23 +256,43 @@ The :mod:`abc` module also provides the following decorators:
and properties are overridden. The abstract properties can be called using
and properties are overridden. The abstract properties can be called using
any of the normal 'super' call mechanisms.
any of the normal 'super' call mechanisms.
Usage::
This special case is deprecated, as the :func:`property` decorator
is now correctly identified as abstract when applied to an abstract
method::
class C(metaclass=ABCMeta):
class C(metaclass=ABCMeta):
@abstractproperty
@property
@abstractmethod
def my_abstract_property(self):
def my_abstract_property(self):
...
...
This defines a read-only property; you can also define a read-write abstract
The above example defines a read-only property; you can also define a
property using the 'long' form of property declaration::
read-write abstract property by appropriately marking one or more of the
underlying methods as abstract::
class C(metaclass=ABCMeta):
class C(metaclass=ABCMeta):
def getx(self): ...
@property
def setx(self, value): ...
def x(self):
x = abstractproperty(getx, setx)
...
@x.setter
@abstractmethod
def x(self, val):
...
If only some components are abstract, only those components need to be
updated to create a concrete property in a subclass::
class D(C):
@C.x.setter
def x(self, val):
...
.. deprecated:: 3.3
.. deprecated:: 3.3
Use :class:`property` with :func:`abstractmethod` instead
It is now possible to use :class:`property`, :meth:`property.getter`,
:meth:`property.setter` and :meth:`property.deleter` with
:func:`abstractmethod`, making this decorator redundant.
.. rubric:: Footnotes
.. rubric:: Footnotes
...
...
Misc/NEWS
Dosyayı görüntüle @
cea27be8
...
@@ -322,6 +322,9 @@ Tools/Demos
...
@@ -322,6 +322,9 @@ Tools/Demos
Documentation
Documentation
-------------
-------------
-
Issue
#
16267
:
Better
document
the
3.3
+
approach
to
combining
@
abstractmethod
with
@
staticmethod
,
@
classmethod
and
@
property
-
Issue
#
15209
:
Clarify
exception
chaining
description
in
exceptions
module
-
Issue
#
15209
:
Clarify
exception
chaining
description
in
exceptions
module
documentation
documentation
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment