So you're referring to function currying, correct? I changed the thread title to reflect that.
--
Ryan
[ERROR]: Your autotools build scripts are 200 lines longer than your program. Something’s wrong.
http://kirbyfan64.github.io/On May 31, 2016 8:04 AM, "Yongsheng Cheng" <cyscoyote@gmail.com> wrote:to begin with: i a deep python funi want to suguest python a feature to support Fuctional Program :,here is the toy code i need a more powerful decrote in moudle functools instead of functools.partial,thanks do you think it is a nice idea?waitting for your replydef minpara(func_1,args):num=0try:func_1(*args)except Exception as error:num,given=re.findall(r'\d+',str(error))[:2]if num:#return int(num),int(given)return (num,given)else:#return func(*args)return (0,0)def curried(func):#@wraps(func)def new_func(*args):num,given=minpara(func,args)#print num,givenif (num,given)==(0,0):return func(*args)else:return curried(functools.partial(func,*args))return new_func@currieddef sun_1(a,b,c):return a+b+c@currieddef sun_2(a,b,c):return a*b*cif __name__=="__main__":print sun_2(1,)(2)(44)print sun_1(1,)(2)(44)print sun_2(1,2)(23)
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/