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

docs.python.org/3/howto/descriptor.html still refers to "unbound methods" #67890

Closed
pfalcon mannequin opened this issue Mar 18, 2015 · 9 comments
Closed

docs.python.org/3/howto/descriptor.html still refers to "unbound methods" #67890

pfalcon mannequin opened this issue Mar 18, 2015 · 9 comments
Assignees
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@pfalcon
Copy link
Mannequin

pfalcon mannequin commented Mar 18, 2015

BPO 23702
Nosy @rhettinger, @pfalcon, @gpshead, @ezio-melotti, @stevendaprano, @vadmium
PRs
  • bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound … #3739
  • [3.6] bpo-23702: Update Descriptor-HOWTO to reflect the removal of unbound methods (GH-3739) #3742
  • 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 2017-09-25.08:16:07.622>
    created_at = <Date 2015-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 = <Date 2017-09-25.08:16:07.622>
    user = 'https://github.com/pfalcon'

    bugs.python.org fields:

    activity = <Date 2017-09-25.08:16:07.622>
    actor = 'rhettinger'
    assignee = 'rhettinger'
    closed = True
    closed_date = <Date 2017-09-25.08:16:07.622>
    closer = 'rhettinger'
    components = ['Documentation']
    creation = <Date 2015-03-18.19:48:34.439>
    creator = 'pfalcon'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 23702
    keywords = ['patch']
    message_count = 9.0
    messages = ['238468', '253167', '293220', '293221', '299738', '299739', '299753', '302918', '302920']
    nosy_count = 8.0
    nosy_names = ['rhettinger', 'pfalcon', 'gregory.p.smith', 'ezio.melotti', 'steven.daprano', 'docs@python', 'martin.panter', 'Johannes Lade']
    pr_nums = ['3739', '3742']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue23702'
    versions = ['Python 3.5', 'Python 3.6']

    @pfalcon
    Copy link
    Mannequin Author

    pfalcon mannequin commented 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).

    @pfalcon pfalcon mannequin assigned docspython Mar 18, 2015
    @pfalcon pfalcon mannequin added the docs Documentation in the Doc dir label Mar 18, 2015
    @ezio-melotti ezio-melotti added the type-bug An unexpected behavior, bug, or error label Mar 18, 2015
    @vadmium
    Copy link
    Member

    vadmium commented Oct 19, 2015

    Current patch for bpo-25435 addresses the code example. Changes to the text are also needed though.

    @stevendaprano
    Copy link
    Member

    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.

    @rhettinger
    Copy link
    Contributor

    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).

    @rhettinger rhettinger assigned rhettinger and unassigned docspython May 8, 2017
    @JohannesLade
    Copy link
    Mannequin

    JohannesLade mannequin commented 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

    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>>

    @JohannesLade
    Copy link
    Mannequin

    JohannesLade mannequin commented 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
    Copy link
    Contributor

    We have a sprint in early September and I'll fix it then.

    @rhettinger
    Copy link
    Contributor

    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
    Copy link
    Contributor

    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

    @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
    docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants