Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation) #69621

Closed
DavidBecher mannequin opened this issue Oct 18, 2015 · 12 comments
Assignees
Labels
3.7 (EOL) end of life docs Documentation in the Doc dir

Comments

@DavidBecher
Copy link
Mannequin

DavidBecher mannequin commented Oct 18, 2015

BPO 25435
Nosy @rhettinger, @dholth, @vadmium, @eryksun, @marco-buttu, @Mariatta
Files
  • 21.diff.txt
  • 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 = <Date 2019-08-29.06:46:53.357>
    created_at = <Date 2015-10-18.18:49:49.065>
    labels = ['3.7', 'docs']
    title = 'Wrong function calls and referring to not removed concepts in descriptor HowTo (documentation)'
    updated_at = <Date 2019-08-29.06:46:53.356>
    user = 'https://bugs.python.org/DavidBecher'

    bugs.python.org fields:

    activity = <Date 2019-08-29.06:46:53.356>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2019-08-29.06:46:53.357>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2015-10-18.18:49:49.065>
    creator = 'David Becher'
    dependencies = []
    files = ['40812']
    hgrepos = []
    issue_num = 25435
    keywords = []
    message_count = 12.0
    messages = ['253159', '253165', '253168', '253202', '270007', '270014', '293162', '293163', '293237', '293252', '302921', '350735']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'dholth', 'docs@python', 'martin.panter', 'eryksun', 'marco.buttu', 'David Becher', 'Mariatta']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue25435'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @DavidBecher
    Copy link
    Mannequin Author

    DavidBecher mannequin commented Oct 18, 2015

    Since Python 3 removed unbound methods, I found some references using the old terminology in this HowTo about descriptors (https://docs.python.org/3/howto/descriptor.html). Also, since unbound methods have been removed, the function call types.MethodType now only takes two arguments, namely the function to bind and the object to bind to. In the current documentation, however, the old function call with three arguments is still being used.

    I made a pull request on github, then I realized that it is just a mirror repo. Attached you will see a patch file with some of the obvious changes that could me made to the document

    @DavidBecher DavidBecher mannequin assigned docspython Oct 18, 2015
    @DavidBecher DavidBecher mannequin added the docs Documentation in the Doc dir label Oct 18, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Oct 19, 2015

    Thanks for the patch. I left a few comments on the code review. I think the class is meant to represent a real function object, not a wrapper. And it would be good to update the following paragraphs about unbound methods.

    Also, it looks like the rest of that page could do with some other updates. E.g. no need for explicit Function(object) base class, no need to mention that a method exists in Python 2.3, code could use @classmethod decorator syntax. But these are a slightly separate issues.

    @vadmium
    Copy link
    Member

    vadmium commented Oct 19, 2015

    Also further up the page, “unbound methods . . . are . . . based on the descriptor protocol” is probably not really correct or useful. bpo-23702 is already open about mentioning unbound methods.

    @rhettinger rhettinger assigned rhettinger and unassigned docspython Oct 20, 2015
    @rhettinger
    Copy link
    Contributor

    I'll update this document to reflect the current state of the world.

    @dholth
    Copy link
    Mannequin

    dholth mannequin commented Jul 8, 2016

    This bit me also. Is there other documentation for how many arguments MethodType() should take?

    @eryksun
    Copy link
    Contributor

    eryksun commented Jul 8, 2016

    I'm surprised it's not documented for the types module:

    https://docs.python.org/3.5/library/types.html#types.MethodType

    At least the docstring has the parameters:

        >>> print(types.MethodType.__doc__)
        method(function, instance)
        
        Create a bound instance method object.

    @vadmium
    Copy link
    Member

    vadmium commented May 6, 2017

    Raymond I suggest you unassign this and let others work on it.

    @Mariatta Mariatta added the 3.7 (EOL) end of life label May 6, 2017
    @rhettinger
    Copy link
    Contributor

    I will have a chance to work on this before long.

    @marco-buttu
    Copy link
    Mannequin

    marco-buttu mannequin commented May 8, 2017

    I also noticed that the howto differentiates between objects and classes:

    "The details of invocation depend on whether obj is an object or a class."

    I think it is misleading, because a class is actually an object. IMHO is better to differentiate between classes and non-classes objects:

    "The details of invocation depend on whether obj is a class or not."

    @rhettinger
    Copy link
    Contributor

    I think it is misleading, because a class is actually an object.

    This is only misleading *after* you know all the interesting details about Python and metaclasses. Prior to that, it is a reasonable and important distinction that I don't want to get lost in weasel words. The calls from object.__getattribute__ are different that those from type.__getattribute__. Likewise, data and non-data descriptors can only be described in terms of objects versus classes. Lastly, descriptors only work when stored in a class, if you store them in instances, they don't get invoked.

    @rhettinger
    Copy link
    Contributor

    I've just updated the section on unbound methods. I'll be working on a number of other improvements over the next few weeks and will incorporate the suggested changes where appropriate.

    @rhettinger
    Copy link
    Contributor

    This was fixed a long time ago.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life docs Documentation in the Doc dir
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants