On 3/20/2012 8:11, Arnaud Delobelle wrote:
On 19 March 2012 23:20, Ian Kelly wrote:
I hope you don't mind if I critique your code a bit!
On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm
wrote:
Here we go.
--->
def genCur(f, unique = True, minArgs = -1):
It is customary in Python for unsupplied ar
On 3/20/2012 0:20, Ian Kelly wrote:
Since you're writing this for Python 3 (as evidenced by the use of the
nonlocal keyword), you could take advantage here of the fact that
Python 3 dictionary views behave like sets. Also, you should use a
more specific exception type:
As a side note, "nonloca
On 19 March 2012 23:20, Ian Kelly wrote:
> I hope you don't mind if I critique your code a bit!
>
> On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm
> wrote:
>> Here we go.
>>
>> --->
>> def genCur(f, unique = True, minArgs = -1):
>
> It is customary in Python for unsupplied arguments with no default to
>
On 3/20/2012 0:20, Ian Kelly wrote:
I hope you don't mind if I critique your code a bit!
Not at all. Thank you for your time.
On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm
wrote:
Here we go.
--->
def genCur(f, unique = True, minArgs = -1):
[...]
I'll update my code following your corrections,
I hope you don't mind if I critique your code a bit!
On Fri, Mar 16, 2012 at 7:21 PM, Kiuhnm
wrote:
> Here we go.
>
> --->
> def genCur(f, unique = True, minArgs = -1):
It is customary in Python for unsupplied arguments with no default to
use the value None, not -1. That's what it exists for.
On 3/17/2012 2:21, Kiuhnm wrote:
Here we go.
I wrote an article about my approach to currying:
http://mtomassoli.wordpress.com/2012/03/18/currying-in-python/
Beginners should be able to understand it as well. Experienced
programmers will probably want to skip some sections.
Kiuhnm
--
http:/
On Sat, 17 Mar 2012 01:46:59 +, Steven D'Aprano wrote:
> On Sat, 17 Mar 2012 02:21:32 +0100, Kiuhnm wrote:
>
>> Here we go.
> [snip code]
>
>
> Have you looked at functools.partial?
>
>
> import functools
> new_func = functools.partial(func, ham, spam=23)
>
>
> (I am aware that, technic
On Sat, 17 Mar 2012 02:21:32 +0100, Kiuhnm wrote:
> Here we go.
[snip code]
Have you looked at functools.partial?
import functools
new_func = functools.partial(func, ham, spam=23)
(I am aware that, technically, currying and partial function application
are not quite the same thing, but it s