What first pops into my head is a dictionary with keys acting as list values and dictionary values defaulting to None, but this feels sub-optimal to me. Can anyone propose a single-structure (i.e. no separate ‘options’ dict) alternative where dict[key] on an item with no flags set returns None and otherwise returns a list of flags? Apologies if I am overlooking some obvious convention.
A simple use for this structure could be an order instance where each item can optionally contain modifications (i.e. no nuts).
Maybe a defaultdict will do:
Prints: