def manage_sheep(flock): preparatory_steps = mock_preparation(); for sheep in flock: if sheep.haswool(): algorithm = "shear_wool"; else: algorithm = "reinvent_care_from_scratch"; try: perform_care(sheep, algorithm); except exception as e: log("failure, but not hidden away, let's learn!", e);