Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8b6b176b
Commit
8b6b176b
authored
Nov 09, 2012
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#16440: fix exception type and clarify example.
parent
5c90436d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
9 deletions
+15
-9
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+15
-9
No files found.
Doc/library/stdtypes.rst
View file @
8b6b176b
...
...
@@ -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 a
n 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 "<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.
...
...
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