method resolution order
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# method resolution order
# mro
class A(object):
def hello(self):
print('class A says hello')
class B(A):
pass
class C(A):
# class variable
BP_URL = 'https://xxxxx'
def __init__(self):
self.name = 'ok'
@staticmethod
def print_hello(name, age):
''' staticmethod
cannot access any class or self variabel/method
'''
pass
@classmethod
def say(cls):
'''class method
can access class level variable/method
'''
print(cls.BP_URL)
def hello(self):
print('class C says hello')
class D(C, B):
pass
if __name__ == '__main__':
d = D()
d.hello()
# to print the mro of one class
print(d.__class__.__mro__)