Skip to content

functools.partial doesn't create bound methods #55913

Closed

Description

@alex
BPO 11704
Nosy @ncoghlan, @alex

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 = None
closed_at = <Date 2014-03-30.06:00:26.240>
created_at = <Date 2011-03-28.21:34:11.038>
labels = ['type-feature', 'docs']
title = "functools.partial doesn't create bound methods"
updated_at = <Date 2014-03-30.06:00:26.239>
user = 'https://github.com/alex'

bugs.python.org fields:

activity = <Date 2014-03-30.06:00:26.239>
actor = 'ncoghlan'
assignee = 'docs@python'
closed = True
closed_date = <Date 2014-03-30.06:00:26.240>
closer = 'ncoghlan'
components = ['Documentation']
creation = <Date 2011-03-28.21:34:11.038>
creator = 'alex'
dependencies = []
files = []
hgrepos = []
issue_num = 11704
keywords = []
message_count = 4.0
messages = ['132425', '132435', '132438', '215169']
nosy_count = 3.0
nosy_names = ['ncoghlan', 'alex', 'docs@python']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue11704'
versions = ['Python 2.7', 'Python 3.2', 'Python 3.3']

Activity

  1. alex commented on Mar 28, 2011

    @alex
    MemberAuthor

    This is related to the discussion we had at the PyCon language summit about C vs Python function binding. If you create a partial instance and put it on a class it doesn't create bound instances. This behavior is a tad surprising in my view. At a minimum it'd be nice if the docs mentioned this.

  2. ncoghlan commented on Mar 28, 2011

    @ncoghlan
    Contributor

    True, this could be documented better - flagging as a docs bug. (It is mentioned at the bottom of http://docs.python.org/library/functools.html#partial-objects, but that could be referenced better from the main documentation of the function higher up in the page)

    There's actually more to it than just an oversight though - partial() fills in positional arguments from the left, so using one as a method would require specification of a carefully crafted selection of positional and keyword arguments to ensure the instance was bound and passed in at the right point.

  3. alex commented on Mar 28, 2011

    @alex
    MemberAuthor

    Indeed I completely missed the section at the bottom. A note in the above section would be a useful addition.

  4. ncoghlan commented on Mar 30, 2014

    @ncoghlan
    Contributor

    With the introduction of functools.partialmethod in 3.4, marking this older docs issue as a "won't fix"

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

No one assigned

    Labels

    docsDocumentation in the Doc dirtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions