[Python-checkins] cpython (merge 3.3 -> default): #16440: merge with 3.3.
ezio.melotti
python-checkins at python.org
Fri Nov 9 00:09:53 CET 2012
http://hg.python.org/cpython/rev/d170844a363f
changeset: 80323:d170844a363f
parent: 80318:ce6fc4531d26
parent: 80322:8c7f2f6f3375
user: Ezio Melotti <ezio.melotti at gmail.com>
date: Fri Nov 09 01:09:27 2012 +0200
summary:
#16440: merge with 3.3.
files:
Doc/library/stdtypes.rst | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -3343,16 +3343,22 @@
Like function objects, bound method objects support getting arbitrary
attributes. However, since method attributes are actually stored on the
underlying function object (``meth.__func__``), setting method attributes on
-bound methods is disallowed. Attempting to set a method attribute results in a
-:exc:`TypeError` being raised. In order to set a method attribute, you need to
-explicitly set it on the underlying function object::
-
- class C:
- def method(self):
- pass
-
- c = C()
- c.method.__func__.whoami = 'my name is c'
+bound methods is disallowed. Attempting to set an attribute on a method
+results in an :exc:`AttributeError` being raised. In order to set a method
+attribute, you need to explicitly set it on the underlying function object::
+
+ >>> class C:
+ ... def method(self):
+ ... pass
+ ...
+ >>> c = C()
+ >>> c.method.whoami = 'my name is method' # can't set on the method
+ Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ AttributeError: 'method' object has no attribute 'whoami'
+ >>> c.method.__func__.whoami = 'my name is method'
+ >>> c.method.whoami
+ 'my name is method'
See :ref:`types` for more information.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list