Nick Coghlan added the comment:

I don't believe it is reasonable to change the behaviour of partial at this 
late stage of the game. It's documented as behaving like staticmethod (albeit 
by not implementing the descriptor protocol at all), so that's no longer 
something we can change. If issue 11470 is added, then we'll just implement the 
staticmethod-like behaviour explicitly rather than leaving it as implicit.

More importantly, the acceptance of PEP 443's functools.singledispatch makes it 
more desirable than ever to support partial binding for method implementations 
*even when the descriptor protocol is not involved*.

Accordingly, I suggest converting this proposal to a separate 
functools.partialmethod API that:

1. When called directly, passes the first positional argument as the first 
positional argument of the underlying function (providing call time binding of 
self, just like a normal function)
2. When retrieved from a class, returns itself
3. When retrieved from an instance, returns an appropriate bound method object 
(providing method lookup time binding of self, just like a normal function)

functools.partial will then continue to behave as it always has (thus posing no 
backwards compatibility risks), while the new partialmethod implementation 
should work with both class descriptor protocol based dispatch (through point 
3) *and* the new functools.singledispatch mechanism (through point 1).

----------
components: +Library (Lib)
nosy: +ncoghlan
title: Can't use _functools.partial() created function as method -> Add 
functools.partialmethod
versions:  -Python 2.7, Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4331>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to