class GraphicMixin: def draw(self): print("Drawing the graphic") class ColorMixin: def set_color(self, color): self.color = color print(f"Setting color to {color}") class ColoredGraphic(ColorMixin, GraphicMixin): pass # 使用 ColoredGraphic 類 colored_graphic = ColoredGraphic() colored_graphic.draw() # 呼叫 GraphicMixin 的方法 colored_graphic.set_color("red") # 呼叫 ColorMixin 的方法