One of the module I learn about is the functools module.
One of the interesting function that I learn is partial, basically it is partial application of a function
for example
read more here
http://docs.python.org/library/functools.html
So you can wrap a existing without rewriting it, but give some default value to the existing function. And is actually used in python decorators.import functoolsdef adder(a,b,c):return a+b+cdef adder2(a,b):return a+badd_three = functools.partial(adder,1,2)add_one = functools.partial(adder2,1)print add_three(1)# would print 4print add_four(3)# would print 6
read more here
http://docs.python.org/library/functools.html
currying?
ReplyDeletebingo, this is what you use to do currying in python....
ReplyDeletepseudo currying anyway