how to implement hierarchical inheritance in python