回覆列表
  • 1 # 使用者834195712159

    程式碼示例:

    # -*- coding:utf-8 -*-

    class Functor(object):

    def __init__(self, func, index=0, *args, **kwargs):

    self._Func = func

    self._Index = index

    self._Args = args

    self._Kwargs = kwargs

    def __call__(self, *args, **kwargs):

    args = args[:self._Index] + self._Args + args[self._Index:]

    kwargs = kwargs.copy()

    kwargs.update(self._Kwargs)

    return self._Func(*args, **kwargs)

    def bind(func, index=0, *args, **kwargs):

    return Functor(func, index, *args, **kwargs)

  • 中秋節和大豐收的關聯?
  • 康乃馨、玫瑰花、杭菊、茉莉花、金桔如何搭配泡水喝?