[issue29005] Possibly incorrect description about method objects
New submission from woo yoo: "In general, calling a method with a list of n arguments is equivalent to calling the corresponding function with an argument list that is created by inserting the method’s object before the first argument." Is above description right? The link is https://docs.python.org/3.5/tutorial/classes.html#method-objects ---------- assignee: docs@python components: Documentation messages: 283556 nosy: docs@python, woo yoo priority: normal severity: normal status: open title: Possibly incorrect description about method objects versions: Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
Jim Fasarakis-Hilliard added the comment: Seems right to me, this is also stated clearly in the reference manual:
When an instance method object is called, the underlying function (__func__) is called, inserting the class instance (__self__) in front of the argument list. For instance, when C is a class which contains a definition for a function f(), and x is an instance of C, calling x.f(1) is equivalent to calling C.f(x, 1).
What doesn't look right to you? ---------- nosy: +Jim Fasarakis-Hilliard _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
woo yoo added the comment: Maybe the last "method's" should be changed into "class instance" ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
Jim Fasarakis-Hilliard added the comment: I see. I'd agree that `instance object` is probably better here. Let's see what others think. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
R. David Murray added the comment: Given the (clearer) explanation in the final paragraph of that section, I think the bare 'object' in the first couple paragraphs should be replaced by 'instance object'. There are multiple objects involved, and that will disambiguate which one is being referred to for insertion as the first argument, and make the language of the section self-consistent. ---------- nosy: +r.david.murray _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
Jim Fasarakis-Hilliard added the comment: I've added a little patch that takes care of this. I didn't add "method's instance object" in the second substitution because it seems evident by the previous sentences. ---------- keywords: +patch Added file: http://bugs.python.org/file45955/method_obj35.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
R. David Murray added the comment: I think it is better to say "the method's instance object", because in the final paragraph we discuss the fact that each method object has an associated instance object. The instance object isn't magically acquired from elsewhere and added, it is added because it has been bound into the method object. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
Jim Fasarakis-Hilliard added the comment: Agreed, attached amended patch ---------- Added file: http://bugs.python.org/file45957/method_obj35_2.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
Roundup Robot added the comment: New changeset 6f89f5eb4422 by R David Murray in branch '3.5': #29005: clarify terminology in tutorial 'method' discussion. https://hg.python.org/cpython/rev/6f89f5eb4422 New changeset 7314e08dc907 by R David Murray in branch '3.6': Merge: #29005: clarify terminology in tutorial 'method' discussion. https://hg.python.org/cpython/rev/7314e08dc907 New changeset 3cc193be79ab by R David Murray in branch 'default': Merge: #29005: clarify terminology in tutorial 'method' discussion. https://hg.python.org/cpython/rev/3cc193be79ab ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
R. David Murray added the comment: Thanks, woo and Jim. ---------- resolution: -> fixed stage: -> resolved status: open -> closed type: -> behavior _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue29005> _______________________________________
participants (4)
-
Jim Fasarakis-Hilliard -
R. David Murray -
Roundup Robot -
woo yoo