是否可以检测 class 是由 class 直接调用还是由基 class 间接调用?

Is it possible to detect whether a class is being called directly by the class or indirectly by a base class?

我正在制作一个包含一些继承 classes 的程序,但我的程序需要知道 class' 函数是直接从 class 还是从基础 class 例如

class Letters():
    def letter(): ...
    ...

class ABC(Letters):
    def __init__(self):
        if from_base_class:
            raise Exception
    def A(): ...
    def B(): ...
    def C(): ...

==== terminal: ====

>>> myclass = ABC()
>>> myclass.letter()
[with all of the line numbers here]
Exception

如何在我的代码中实现它?

那么您是要提出异常吗?

class Letters():
    def letter(self): ...
    ...

class ABC(Letters):
    def letter(self):
        raise NotImplementedError