【发布时间】:2020-02-27 04:16:15
【问题描述】:
我尝试用functools.lru_cache 装饰classmethod。我的尝试失败了:
import functools
class K:
@functools.lru_cache(maxsize=32)
@classmethod
def mthd(i, stryng: str): \
return stryng
obj = K()
错误信息来自functools.lru_cache:
TypeError: the first argument must be callable
【问题讨论】:
-
classmethod必须最后使用.. 这意味着它必须位于装饰器链的顶部
标签: python python-3.x decorator static-methods python-decorators