rantingrick wrote: > On Jul 6, 6:44 am, Steven D'Aprano <steve > +comp.lang.pyt...@pearwood.info> wrote: > >> A control structure is a structure which controls the program flow. >> Control structures include: >> >> * jumps (goto, gosub, comefrom, exceptions, break, continue) >> >> * loops (for, while, repeat...until) >> >> * conditional branches (if, case/switch) > > ------------------------------------------- > THIS CODE RESULTS IN A CONTROL STRUCTURE! > > --> lst.sort(lambda x,y: cmp(x[1], y[1]))
No it doesn't. How does it change the program flow? You call the sort method, it sorts, and execution continues at the next statement. Regardless of whether you supply a cmp function or not, the program flow is identical: ENTER SORT ROUTINE PERFORM SORTING EXIT SORT ROUTINE There is no control transferred. It is a linear program flow: in, do the job, out again. Since it doesn't modify the program flow, it is not a control structure. "Perform sorting" is a black box. It could have loops, branches, unconditional exists. It could have COMEFROM statements up the wazoo, if it were implemented in a language with COMEFROM (like Intercal). None of that matters two bits: the caller cannot use sort to modify the execution sequence around it, therefore it's not a control structure. No matter how much the sort routine jumps around internally, you can't use that change program flow around it. print surely is implemented with a loop: it has to loop over a string and write it to stdout. Would you say that therefore print is a control structure: ENTER PRINT STATEMENT PERFORM PRINTING EXIT PRINT STATEMENT One entry, one exit. -- Steven -- http://mail.python.org/mailman/listinfo/python-list