Background: I need to render the same information in two text formats. To do this, I have a set of model classes that store the appropriate information. I then need to render that same information in two different ways.
Each model has a list of 'actions'. Different actions have different attributes.
How do I handle this in my rendering code without a switch on the type of action? I'm working on the assumption that a switch statement on object type is a bad thing.
if isinstance(action, ActionOne): render_action_one(action) elif isinstance(action, ActionTwo): render_action_two(action)
The action classes, being part of the model, don't know how to do this rendering.
Edit: This happens to be in Python, but I don't think that matters so much here.