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: functools.partial doesn't create bound methods
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: docs@python Nosy List: alex, docs@python, ncoghlan
Priority: normal Keywords:

Created on 2011-03-28 21:34 by alex, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (4)
msg132425 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2011-03-28 21:34
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.
msg132435 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2011-03-28 22:27
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.
msg132438 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2011-03-28 22:29
Indeed I completely missed the section at the bottom.  A note in the above section would be a useful addition.
msg215169 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2014-03-30 06:00
With the introduction of functools.partialmethod in 3.4, marking this older docs issue as a "won't fix"
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55913
2014-03-30 06:00:26ncoghlansetstatus: open -> closed
type: enhancement
messages: + msg215169

resolution: wont fix
stage: resolved
2011-03-28 22:29:52alexsetmessages: + msg132438
2011-03-28 22:27:46ncoghlansetnosy: + docs@python, ncoghlan
messages: + msg132435

assignee: docs@python
components: + Documentation
2011-03-28 21:34:11alexcreate