English


Python supports two types of loops: for and while. Both of them have a condition and may have break and continue statements inside. The decision of what graphics to use to draw the loops was a hard one. Here are a few considerations.

A traditional flowchart graphics primitive used for loops is already occupied by the if statements and I rather keep it this way because I don't see any good alternatives for if statements.

On the other hand a loop has a very definitive point where it begins and where it ends so it reminds a scope for the loop body with a loop condition in the scope header. Another consideration is that in case of a scope primitive for loops the idea of the main line of execution is expressed more naturally than in case of a traditional flowchart primitive. This is actually about the connectors. The scope primitive would have an exit point at the bottom while the traditional primitive would have it at the right hand side of a header. Another problem with the traditional graphics comes up when we talk about the else clauses supported by Python loops. There is nothing like that in the traditional flowchart diagrams and it is hard to suggest something for them.

The last consideration is the break and continue statements. If a scope primitive is used then the points to where break and continue should lead become very well visible: at the bottom and at the top of the rounded rectangle. Otherwise explicit connectors would be required and it would be hard to draw them automatically without crossing the other graphics.

Having the scope idea for the loops the question with the leading and side comments could also be resolved easily.

So I decided to stick on the scope primitives for Python loops.