[Python-Dev] Partial function application 'from the right' (original) (raw)

Collin Winter collinw at gmail.com
Tue Feb 3 19:11:47 CET 2009


On Tue, Feb 3, 2009 at 5:44 AM, Ben North <ben at redfrontdoor.org> wrote:

Hi,

Thanks for the further responses. Again, I'll try to summarise: Scott David Daniels pointed out an awkward interaction when chaining partial applications, such that it could become very unclear what was going to happen when the final function is called:

If you have: def button(root, position, action=None, text='*', color=None): ... ... bluebutton = partial(button, myroot, color=(0,0,1))

Should partialright(bluebutton, 'red') change the color or the text? Calvin Spealman mentioned a previous patch of his which took the 'hole' approach, i.e.: [...] my partial.skip patch, which allows the following usage: splitone = partial(str.split, partial.skip, 1) This would solve my original problems, and, continuing Scott's example, def onclicked(...): ... = partial.skip clickablebluebutton = partial(bluebutton, , onclicked) has a clear enough meaning I think: clickablebluebutton('top-left corner') = bluebutton('top-left corner', onclicked) = button(myroot, 'top-left corner', onclicked, color=(0,0,1)) Calvin's idea/patch sounds good to me, then. Others also liked it. Could it be re-considered, instead of the partialright idea?

Have any of the original objections to Calvin's patch (http://bugs.python.org/issue1706256) been addressed? If not, I don't see anything in these threads that justify resurrecting it.

I still haven't seen any real code presented that would benefit from partial.skip or partial_right.

Collin Winter



More information about the Python-Dev mailing list