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: Possible error on the descriptor howto guide
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, kamilturek, marcosmodenesi, miss-islington, rhettinger
Priority: normal Keywords: patch

Created on 2021-03-07 15:42 by marcosmodenesi, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 24787 merged rhettinger, 2021-03-08 21:24
PR 24849 merged miss-islington, 2021-03-13 21:46
Messages (6)
msg388239 - (view) Author: Marcos M (marcosmodenesi) Date: 2021-03-07 15:42
> To recap, functions have a __get__() method so that they can be converted to a method when accessed as attributes. The non-data descriptor transforms an obj.f(*args) call into f(obj, *args). Calling cls.f(*args) becomes f(*args).

I THINK it should say

cls.f(*args) becomes f(cls, *args)

as stated in the table that follows that paragraph.
msg388240 - (view) Author: Marcos M (marcosmodenesi) Date: 2021-03-07 15:43
Let me provide a link to ease finding this piece of documentation

https://docs.python.org/3/howto/descriptor.html#static-methods
msg388281 - (view) Author: Kamil Turek (kamilturek) * Date: 2021-03-08 18:49
I think there isn't any error. Please look at the example provided in the guide:

class E:
    @staticmethod
    def f(x):
        print(x)

>>> E.f(3)
3

If it were as you say, method would receive two arguments - f(E, 3) - which is wrong.
msg388293 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-03-08 19:53
I can see how that section intro is a bit confusing.  Am thinking it will be more clear if the heading "Static Methods" is to moved to just after the table showing the three variants.  Otherwise, it looks like the intro text is talking specifically about static methods.
msg388637 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-03-13 21:46
New changeset f00e82f8b87c96ff76d6f768fa7a29cbd86eec6a by Raymond Hettinger in branch 'master':
bpo-43427:  Separte the method overview from the static method specifics. (GH-24787)
https://github.com/python/cpython/commit/f00e82f8b87c96ff76d6f768fa7a29cbd86eec6a
msg388647 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-03-14 02:31
New changeset 45d9c8cda3db7da9fe209bd215ec9a120265ee65 by Miss Islington (bot) in branch '3.9':
bpo-43427:  Separte the method overview from the static method specifics. (GH-24787) (GH-24849)
https://github.com/python/cpython/commit/45d9c8cda3db7da9fe209bd215ec9a120265ee65
History
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87593
2021-03-14 02:32:10rhettingersetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.10
2021-03-14 02:31:44rhettingersetmessages: + msg388647
2021-03-13 21:46:44miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request23610
2021-03-13 21:46:41rhettingersetmessages: + msg388637
2021-03-08 21:24:12rhettingersetkeywords: + patch
stage: patch review
pull_requests: + pull_request23553
2021-03-08 19:53:07rhettingersetmessages: + msg388293
2021-03-08 19:14:50rhettingersetassignee: docs@python -> rhettinger
2021-03-08 18:49:24kamiltureksetnosy: + kamilturek
messages: + msg388281
2021-03-07 16:17:37xtreaksetnosy: + rhettinger
2021-03-07 15:43:40marcosmodenesisetmessages: + msg388240
2021-03-07 15:42:35marcosmodenesicreate