python的super函數示例

開始:

class A(object):
    def __init__(self):
        print("ctor A beg")
        print("ctor A end")


class B(A):
    def __init__(self):
        print("ctor B beg")
        super(B, self).__init__()
        print("ctor B end")


b = B()
# 輸出信息如下所示:
# ctor B beg
# ctor A beg
# ctor A end
# ctor B end

完。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章