interpreter pattern the composite pattern defines both composite ( non-terminalsclasses and leaf ( terminalsclasses that can be used to construct composite componentsuch as special rule class leaf(object)def __init__(self*args**kwargs)pass def component_function(self)print("leaf"class composite(object)def __init__(self*args**kwargs)self children [def component_function(self)for child in childrenchild component_function(def add(selfchild)self children append(childdef remove(selfchild)self children remove(childin less dynamic languagesyou would have also had to define super class that would be inherited by both the composite and the leaf classesbut since python uses duck typingwe are once again saved from creating unnecessary boilerplate code internal dsl implementation using the composite pattern let us consider an implementation of the first rule for discounts from the restaurant in the beginning of this as some rudimentary internal dsl class tab(object)def __init__(selfcustomer)self items [self discounts [self customer customer