当前位置:首页 > Python教程 > python技巧

代码杂谈-python函数

  • 发现函数可以设置属性变量, 如下 newfunc.func , newfunc.args
        def partial(func, *args, **keywords):
   """Copied from Python standard lib functools.

   https://docs.python.org/2/library/functools.html#functools.partial
   Simply importing from the standard module caused failure in UDFs.
   """

   def newfunc(*fargs, **fkeywords):
     newkeywords = keywords.copy()
     newkeywords.update(fkeywords)
     return func(*(args + fargs), **newkeywords)

   newfunc.func = func
   newfunc.args = args
   newfunc.keywords = keywords
   return newfunc
    

原文:https://www.cnblogs.com/bregman/p/11811329.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!

相关教程推荐

其他课程推荐