5.2. Basic Control Structures

Python's WYSIWYG code layout philosophy is at the core of how Python programs are constructed. Control structures such as code repetition and code selection use indentation to express the grouping of code statements.

In this section, we talk a little about the philosophy behind this WYSIWYG approach and then look at the most important control structures provided by Python.

5.2.1. Some WYSIWYG Code Layout Philosophy

Here is a simple algorithm in the C programming language that uses braces to control statement grouping. Languages such as C++, Perl, and Java™ also take this general approach to statement grouping.

 CD-ROM reference=5001.txt while (alive) { if (hungry) { eat(); if (thirsty) { drink(); } } else { WriteSoftware(); ...

Get XML Processing with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.