From 8b6b176b33ee8c3074b463a4628faa84dea0ebed Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Fri, 9 Nov 2012 01:08:25 +0200 Subject: #16440: fix exception type and clarify example. --- Doc/library/stdtypes.rst | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 1d7467d..f6eca56 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -2659,16 +2659,22 @@ arg-n)``. 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:: +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.__func__.whoami = 'my name is c' + >>> 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 "", line 1, in + 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. -- cgit v0.12