Skip to content

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

Closed

Description

@pfalcon
mannequin
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']

    Activity

    1. pfalcon commented on Mar 18, 2015

      pfalconmannequin
      MannequinAuthor

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

    2. vadmium commented on Oct 19, 2015

      @vadmium
      Member

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

    3. stevendaprano commented on May 8, 2017

      @stevendaprano
      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.

    4. rhettinger commented on May 8, 2017

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

    5. JohannesLade commented on Aug 4, 2017

      JohannesLademannequin
      Mannequin

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

    6. JohannesLade commented on Aug 4, 2017

      JohannesLademannequin
      Mannequin

      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.

    7. rhettinger commented on Aug 4, 2017

      @rhettinger
      Contributor

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

    8. rhettinger commented on Sep 25, 2017

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

    9. rhettinger commented on Sep 25, 2017

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

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    docsDocumentation in the Doc dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions