This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: docs.python.org/3/howto/descriptor.html still refers to "unbound methods"
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: Johannes Lade, docs@python, ezio.melotti, gregory.p.smith, martin.panter, pfalcon, rhettinger, steven.daprano
Priority: normal Keywords: patch

Created on 2015-03-18 19:48 by pfalcon, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3739 merged rhettinger, 2017-09-24 23:53
PR 3742 merged python-dev, 2017-09-25 08:06
Messages (9)
msg238468 - (view) Author: Paul Sokolovsky (pfalcon) * Date: 2015-03-18 19:48
Under https://docs.python.org/3/howto/descriptor.html#functions-and-methods , there're several references to unbound methods (including in expected output from the interpreter).

As known, unbound methods are gone in Python3, so seeing those are confusing. (I didn't sharply know that unbound methods are gone from Py3, so was pretty confused by the examples there, comparing them with actual output of Cpython 3.4).
msg253167 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-10-19 03:26
Current patch for Issue 25435 addresses the code example. Changes to the text are also needed though.
msg293220 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2017-05-08 00:59
Be careful with the documentation patch. Although unbound method as an object type is gone, unbound method as a concept is not.

Conceptually, something like ``MyClass.spam`` is an unbound method: it is a method of the MyClass type, but bound to no instance. In Python 2 that concept was implemented by MethodType. In Python 3, the concept is implemented by FunctionType.

While it is certainly true from one perspective that unbound methods are nothing but functions, it is nevertheless also sometimes useful to distinguish from "functions defined in a class" (methods) and "other functions". I think that nearly all Python programmers would be happy to call ``spam`` below:

    class MyClass:
        def spam(self, arg): ...

a method, even though it is also/really a function.
msg293221 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-05-08 01:17
I'll fix that up.  I've already been working on revising the document.  There are a number of updates needed (user-friendly intro, properties revised to show the setting methods, __set_name__, etc).
msg299738 - (view) Author: Johannes Lade (Johannes Lade) Date: 2017-08-04 11:41
This is still a problem. Can please somebody fix this? There are already enough confusing discussion full of wrong information about this topic, so it would be nice if the official documentation would get it right. Also there's multiple Issues for this. Can they be combined into one?
Just one example I found: on https://docs.python.org/3.5/howto/descriptor.html#functions-and-methods

Documentation:
>>> class D(object):
...     def f(self, x):
...         return x
...
>>> d = D()
>>> D.__dict__['f']  # Stored internally as a function
<function f at 0x00C45070>
>>> D.f              # Get from a class becomes an unbound method
<unbound method D.f>
>>> d.f              # Get from an instance becomes a bound method
<bound method D.f of <__main__.D object at 0x00B18C90>>

ipython3.5.3
In [1]: class D(object):
   ...: ...     def f(self, x):
   ...: ...         return x
   ...: ...

In [2]: d = D()

In [3]: D.__dict__['f']  # Stored internally as a function
Out[3]: <function __main__.D.f>

In [4]: D.f              # Get from a class becomes an unbound method
Out[4]: <function __main__.D.f>

In [5]: d.f              # Get from an instance becomes a bound method
Out[5]: <bound method D.f of <__main__.D object at 0x7f4e2e278c18>>
msg299739 - (view) Author: Johannes Lade (Johannes Lade) Date: 2017-08-04 11:44
And sorry for my lousy manners. Of course I appreciate all the hard work you do! It's just frustrating when you get confused by doc.
msg299753 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-08-04 15:33
We have a sprint in early September and I'll fix it then.
msg302918 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-09-25 08:05
New changeset 0d4497b9cae7942b7f731a6f99a73985c3fb4630 by Raymond Hettinger in branch 'master':
bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound methods (#3739)
https://github.com/python/cpython/commit/0d4497b9cae7942b7f731a6f99a73985c3fb4630
msg302920 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-09-25 08:11
New changeset 73c915a5cd1cdd8775cf47b77fef7ca8fd42ad96 by Raymond Hettinger (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound methods (GH-3739) (#3742)
https://github.com/python/cpython/commit/73c915a5cd1cdd8775cf47b77fef7ca8fd42ad96
History
Date User Action Args
2022-04-11 14:58:14adminsetgithub: 67890
2017-09-25 08:16:07rhettingersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-09-25 08:15:17rhettingersetdependencies: - Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)
2017-09-25 08:11:23rhettingersetmessages: + msg302920
2017-09-25 08:06:03python-devsetpull_requests: + pull_request3729
2017-09-25 08:05:52rhettingersetmessages: + msg302918
2017-09-24 23:53:35rhettingersetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request3725
2017-08-04 15:33:19rhettingersetmessages: + msg299753
2017-08-04 11:44:29Johannes Ladesetmessages: + msg299739
2017-08-04 11:41:14Johannes Ladesetnosy: + Johannes Lade
messages: + msg299738
2017-05-08 01:17:18rhettingersetpriority: high -> normal

nosy: + rhettinger
messages: + msg293221

assignee: docs@python -> rhettinger
2017-05-08 00:59:10steven.dapranosetnosy: + steven.daprano
messages: + msg293220
2017-05-06 14:20:15martin.panterlinkissue30292 superseder
2016-08-25 21:29:42gregory.p.smithsetpriority: normal -> high
nosy: + gregory.p.smith
2016-01-03 09:58:39ezio.melottisetversions: + Python 3.5, Python 3.6, - Python 3.4
2015-10-19 03:26:18martin.pantersetnosy: + martin.panter
dependencies: + Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)
messages: + msg253167
2015-03-18 20:28:03ezio.melottisetnosy: + ezio.melotti

type: behavior
stage: needs patch
2015-03-18 19:48:34pfalconcreate