Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Paddy
Aha! Thanks Ian for this new snippet. It is what I will use for my current example. (But please see my third posting on this too). -- http://mail.python.org/mailman/listinfo/python-list

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Paddy
Thanks Ian, Benjamin, and Steven. I now know why it works as it does. Thinking about it a little more, Is it reasonable to *expect* partial acts as it does, rather than this way being an implementation convenience? (That was written as a straight question not in any way as a dig). I had though

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Ian Kelly
On Fri, Mar 25, 2011 at 1:03 AM, Ian Kelly wrote: > Moral of the story: if you pass in an argument by keyword, then the > following arguments must be passed by keyword as well (or not at all), > regardless of whether you're using partial or not. To be clear, you can also just pass f1 into partial

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Steven D'Aprano
On Thu, 24 Mar 2011 23:30:29 -0700, Paddy wrote: > Hi, I just found the following oddity where for function fsf1 I am > forced to use a named parameter for correct evaluation and was wondering > why it doesn't work, yet the example from the docs of wrapping int to > create basetwo doesn't need thi

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Ian Kelly
On Fri, Mar 25, 2011 at 12:30 AM, Paddy wrote: def fs(f, s): return [f(value) for value in s] Note that your "fs" is basically equivalent to the "map" builtin, minus some of the features. fsf1 = partial(fs, f=f1) fsf1(s) > Traceback (most recent call last): >  File "", line 1, in

Re: functools.partial doesn't work without using named parameter

2011-03-25 Thread Benjamin Kaplan
On Fri, Mar 25, 2011 at 2:30 AM, Paddy wrote: > Hi, I just found the following oddity where for function fsf1 I am forced to > use a named parameter for correct evaluation and was wondering why it doesn't > work, yet the example from the docs of wrapping int to create basetwo doesn't > need thi

Re: functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
P.S: Python 3.2! -- http://mail.python.org/mailman/listinfo/python-list

functools.partial doesn't work without using named parameter

2011-03-24 Thread Paddy
Hi, I just found the following oddity where for function fsf1 I am forced to use a named parameter for correct evaluation and was wondering why it doesn't work, yet the example from the docs of wrapping int to create basetwo doesn't need this? The example: >>> from functools import partial >>>