class Foo: attr = "Common" def __init__(self, arg1, arg2): self.attr1 = arg1 self.attr2 = arg2 def use_me(self): print("Foo: use_me") def poly(self): print("Foo: poly") class Bar(Foo): def something_new(self): print("Bar: something_new") def poly(self): print("Bar: poly") class XYZ: def xyz(self): print("XYZ: xyz") def poly(self): print("XYZ: poly") class Strange(Bar, XYZ): pass def main(): f = Foo(1, 3) b = Bar(1, 3) xyz = XYZ() s = Strange(1, 3) f.poly() # Foo: poly b.poly() # Bar: poly xyz.poly() # XYZ: poly # Saying the truth, this is not # a true polymorphism because # each element of the collection # is different type and is treated # as different type. collection = [f, b, xyz] for e in collection: print(type(e)) e.poly() ''' Foo: poly Bar: poly XYZ: poly ''' if __name__ == '__main__': main()