python - 我如何知道在 Python 3 中将调用哪个方法?
问题描述
我的练习中有这些课程:
class A:
def accept(self,v):
v.visitA(self)
class B(A):
def accept(self,v):
v.visitB(self)
class C:
def accept(self,v):
v.visitC(self)
class Visitor:
def visitA(self,x):
return x.accept(self)
def visitB(self,x):
pass
def visitC(self,x):
pass
我的问题是,x.accept(self)
在访问者类的方法 visitA 中可以(间接)调用访问者类的哪个方法?尽管阅读了有关 python 继承的信息,但我并不真正理解这些代码。有没有人可以帮我解释这段代码?先感谢您!
解决方案
推荐阅读
- sql - 在 SQL 中对包含整数的字符串进行排序
- python - 给定一个带有子目录的目录,我怎样才能找到文件的路径?
- swift - 使用 PickerViewer 从 Firestore 过滤数据后,我无法将数据发送到另一个 VC
- java - 网络调用完成时 Java 同步返回
- qlikview - 如果未进行任何选择,QlikView 使按钮不可点击
- asp.net - 报告页脚部分显示时如何抑制页脚部分?
- excel - 如何正确比较 VBA excel 中的十进制字符?
- ios - 离子卡在 iPhone 中滚动缓慢
- php - 删除 symfony 路由组件中的默认语言环境前缀
- azure-devops - 如何在 Azure DevOps 中通过电子邮件发送管道工件?