[Python-ideas] Make partial a built-in

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Sep 21 01:44:36 EDT 2016


אלעזר wrote:
> @partial(partial, partial(partial, partial)) 
> def add(a, b, c): return a + b + c

For large numbers of arguments, it's much clearer if you
write it this way:

 >>> from functools import partial as badger, partial as mushroom
 >>> @badger(badger, badger(badger, badger(badger, mushroom)))
... def add(a,b,c,d):
...  return a+b+c+d
...
 >>> add(1)(2)(3)(4)
10

-- 
Greg


More information about the Python-ideas mailing list