小编ism*_*DEN的帖子

如何在继承文件的装饰器函数中获取python文件名

我有一个主类和继承类。我在主类中有一个装饰器函数。下面的代码位于base.py 中。

def functionErrorCase(functionParam):
    def wrapper(self):
        try:
            functionParam(self)
        except Exception as e:
            self.InsertError(os.path.basename(__file__), functionParam.__name__)
    return wrapper
Run Code Online (Sandbox Code Playgroud)

用于继承类“__ file __”中的所有函数命令返回base.py文件名,但我想要所使用类的文件名

如何返回使用的类文件名?

python python-3.x

2
推荐指数
1
解决办法
1096
查看次数

标签 统计

python ×1

python-3.x ×1