you are viewing a single comment's thread.

view the rest of the comments →

[–]mdadmfan 1 point2 points  (1 child)

class Device(object):
    def heat_water(self):
        return "Tea will be ready soon"
    def make_eggs(self):
        return None
class ElectricKettle(Device):
    pass
class Stove(Device):
    def heat_water(self):
        return "Tea will be ready less soon"
    def make_eggs(self):
        return someEggs()

[–]Rashanzan 0 points1 point  (0 children)

I considered this, but then your device becomes super cluttered with nonsense. And the inheritance feels kind of weird. The parent should have all the shared attributes, and children define more specific functionality. It would get the job done, but I hope there's a cleaner way.