[Python-checkins] r81332 - in python/branches/release26-maint: Doc/reference/datamodel.rst

georg.brandl python-checkins at python.org
Wed May 19 16:04:44 CEST 2010


Author: georg.brandl
Date: Wed May 19 16:04:44 2010
New Revision: 81332

Log:
Merged revisions 77603 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77603 | benjamin.peterson | 2010-01-19 00:07:56 +0100 (Di, 19 Jan 2010) | 8 lines
  
  data descriptors do not override the class dictionary if __get__ is not defined
  
  Adjust documentation and add a test to verify this behavior.
  
  See http://mail.python.org/pipermail/python-dev/2010-January/095637.html for
  discussion.
........


Modified:
   python/branches/release26-maint/   (props changed)
   python/branches/release26-maint/Doc/reference/datamodel.rst

Modified: python/branches/release26-maint/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/release26-maint/Doc/reference/datamodel.rst	(original)
+++ python/branches/release26-maint/Doc/reference/datamodel.rst	Wed May 19 16:04:44 2010
@@ -1603,11 +1603,17 @@
    ``A.__dict__['m'].__get__(obj, A)``.
 
 For instance bindings, the precedence of descriptor invocation depends on the
-which descriptor methods are defined.  Normally, data descriptors define both
-:meth:`__get__` and :meth:`__set__`, while non-data descriptors have just the
-:meth:`__get__` method.  Data descriptors always override a redefinition in an
+which descriptor methods are defined.  A descriptor can define any combination
+of :meth:`__get__`, :meth:`__set__` and :meth:`__delete__`.  If it does not
+define :meth:`__get__`, then accessing the attribute will return the descriptor
+object itself unless there is a value in the object's instance dictionary.  If
+the descriptor defines :meth:`__set__` and/or :meth:`__delete__`, it is a data
+descriptor; if it defines neither, it is a non-data descriptor.  Normally, data
+descriptors define both :meth:`__get__` and :meth:`__set__`, while non-data
+descriptors have just the :meth:`__get__` method.  Data descriptors with
+:meth:`__set__` and :meth:`__get__` defined always override a redefinition in an
 instance dictionary.  In contrast, non-data descriptors can be overridden by
-instances. [#]_
+instances.
 
 Python methods (including :func:`staticmethod` and :func:`classmethod`) are
 implemented as non-data descriptors.  Accordingly, instances can redefine and
@@ -2476,13 +2482,6 @@
    controlled conditions. It generally isn't a good idea though, since it can
    lead to some very strange behaviour if it is handled incorrectly.
 
-.. [#] A descriptor can define any combination of :meth:`__get__`,
-   :meth:`__set__` and :meth:`__delete__`.  If it does not define :meth:`__get__`,
-   then accessing the attribute even on an instance will return the descriptor
-   object itself.  If the descriptor defines :meth:`__set__` and/or
-   :meth:`__delete__`, it is a data descriptor; if it defines neither, it is a
-   non-data descriptor.
-
 .. [#] For operands of the same type, it is assumed that if the non-reflected method
    (such as :meth:`__add__`) fails the operation is not supported, which is why the
    reflected method is not called.


More information about the Python-checkins mailing list