python继承关系之super函数
来源:互联网 发布:网络用语dw什么意思 编辑:程序博客网 时间:2024/05/17 22:08
super_example.py
class A:def __init__(self):print("Enter A")print("Leave A")class B(A):def __init__(self):print("Enter B")super(B,self).__init__()print("Leave B")class C(A):def __init__(self):print("Enter C")super(C,self).__init__()print("Leave C")class D(A):def __init__(self):print("Enter D")super(D,self).__init__()print("Leave D")class E(B,C,D):def __init__(self):print("Enter E")super(E,self).__init__()print("Leave E")
from super_example import *info = E()
结果:
Enter E
Enter B
Enter C
Enter D
Enter A
Leave A
Leave D
Leave C
Leave B
Leave E
总结:
super的特点类似于BFS,继承的上一层遍历完后,再向上一层继承关系遍历,全部遍历完后,递归返回
,所以出现了上述输出结果,可以看到前后是对称的,与递归调用的特点极其类似.
阅读全文
0 0
- python继承关系之super函数
- Python之super函数
- Python 中的继承之Super用法
- python 之 super函数学习
- 关于Python中的类普通继承与super函数继承
- Python super继承详解
- java继承关系super用法
- Python之自动生成代码继承关系
- python super 继承
- python普通继承和super继承
- Python super函数
- Python深入:super函数
- python-super函数
- Python-理解super函数
- python super()函数
- Python super() 函数
- java学习之继承,super
- python 关键字之super
- 洛谷P1045 麦森数
- IntelliJ Idea 常用快捷键列表
- EJB开发第一期---EJB开发配置
- Python基础总结(3)
- 建立LDA模型
- python继承关系之super函数
- 求星期几的问题
- java 三种outofmemory异常
- qt开发环境
- IntelliJ IDEA导航特性Top20
- poj3268Silver Cow Party之dijkstra解法
- JAVA编程题(初级):输入10个整数,排序后输出。
- 文章标题
- JZOJ1228. Matrix(2017.8B组)