Decorators with parameters?

前端 未结 13 1422
我在风中等你
我在风中等你 2020-11-21 22:58

I have a problem with the transfer of variable \'insurance_mode\' by the decorator. I would do it by the following decorator statement:

@execute_complete_rese         


        
13条回答
  •  情话喂你
    2020-11-21 23:16

    define this "decoratorize function" to generate customized decorator function:

    def decoratorize(FUN, **kw):
        def foo(*args, **kws):
            return FUN(*args, **kws, **kw)
        return foo
    

    use it this way:

        @decoratorize(FUN, arg1 = , arg2 = , ...)
        def bar(...):
            ...
    

提交回复
热议问题