collection get_initial_state(state_var none for datum in data_setif condition(state_var)state_var calculate_from(datumnew modify(datumstate_varcollection add_to(newelsenew modify_differently(datumcollection add_to(newnow actually work with the data for thing in collectionprocess(thingwe might simply remove the "howof the data construction from the current scopeand tuck it away in function that we can think about in isolation (or not think about at all once it is sufficiently abstractedfor exampletuck away construction of data def make_collection(data_set)collection get_initial_state(state_var none for datum in data_setif condition(state_var)state_var calculate_from(datumstate_varnew modify(datumstate_varcollection add_to(newelsenew modify_differently(datumcollection add_to(newreturn collection now actually work with the data for thing in make_collection(data_set)process(thingwe haven' changed the programming logicnor even the lines of codeat allbut we have still shifted the focus from "how do we construct collection?to "what does make_collection(create?comprehensions using comprehensions is often way both to make code more compact and to shift our focus from the "howto the "what comprehension is an expression that uses the same keywords as loop and conditional blocksbut inverts their order to focus on the data (avoidingflow control