Nick Coghlan added the comment: To clarify the current state of this:
- I'm still in favour of adding this feature for Python 3.4 - a suitable patch is still needed, as the currently attached patches modify the existing functools.partial object, rather than adding a separate "partialmethod" API - a Python implementation would be fine The following prototype should work as a starting point to be elaborated into a full patch with docs and tests: class partialmethod(functools.partial): def __get__(self, obj, cls): if obj is None: return self return functools.partial(self.func, *((obj,) + self.args), **self.keywords) def __call__(*args, **kwds): self, *args = args call_kwds = {} call_kwds.update(self.keywords) call_kwds.update(kwds) return self.func(self, *(self.args + args), **call_kwds) class C: def example(self, *args, **kwds): print(self, args, kwds) fails = functools.partial(example, 1, 2, 3, x=1) works = partialmethod(example, 1, 2, 3, x=1) >>> C().fails() 1 (2, 3) {'x': 1} >>> C().works() <__main__.C object at 0x7f91cefeea90> (1, 2, 3) {'x': 1} >>> C().fails(4, 5, 6) 1 (2, 3, 4, 5, 6) {'x': 1} >>> C().works(4, 5, 6) <__main__.C object at 0x7f91cefeea10> (1, 2, 3, 4, 5, 6) {'x': 1} ---------- stage: -> needs patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue4331> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com