You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docs.python.org/3/howto/descriptor.html still refers to "unbound methods" #67890
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/rhettinger'closed_at=<Date2017-09-25.08:16:07.622>created_at=<Date2015-03-18.19:48:34.439>labels= ['type-bug', 'docs']
title='docs.python.org/3/howto/descriptor.html still refers to "unbound methods"'updated_at=<Date2017-09-25.08:16:07.622>user='https://github.com/pfalcon'
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).
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:
classMyClass:
defspam(self, arg): ...
a method, even though it is also/really a function.
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).
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:
>>> classD(object):
... deff(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>>
JohannesLade commented on Aug 4, 2017
JohannesLademannequin
Mannequin
More actions
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.
New changeset 0d4497b by Raymond Hettinger in branch 'master': bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound methods (bpo-3739) 0d4497b
New changeset 73c915a 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) (bpo-3742) 73c915a
Activity
pfalcon commentedon Mar 18, 2015
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).
vadmium commentedon Oct 19, 2015
Current patch for bpo-25435 addresses the code example. Changes to the text are also needed though.
stevendaprano commentedon May 8, 2017
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.spamis 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
spambelow:a method, even though it is also/really a function.
rhettinger commentedon May 8, 2017
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).
JohannesLade commentedon Aug 4, 2017
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
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>>
JohannesLade commentedon Aug 4, 2017
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.
rhettinger commentedon Aug 4, 2017
We have a sprint in early September and I'll fix it then.
rhettinger commentedon Sep 25, 2017
New changeset 0d4497b by Raymond Hettinger in branch 'master':
bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound methods (bpo-3739)
0d4497b
rhettinger commentedon Sep 25, 2017
New changeset 73c915a 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) (bpo-3742)
73c915a