Now that we have introduced compound statements, you may need to
make an adjustment to your editor. Set your editor to use spaces instead
of tabs. Most Python is typed using four spaces instead of the ASCII tab
character (^I). Most editors can be set so that when you hit the
key on your keyboard, the editor inserts four spaces.
IDLE is set up this way by default. A good
editor will follow the indents so that once you indent, the next line is
We'll show the spaces explicitly as ␣'s in the following
This is has typical spacing for a piece of Python
Note that the colon (:) immediately follows the condition. This is
the usual format, and is consistent with the way natural languages (like
English) are formatted.
statements can be collapsed to
one-liners, in which case they would look like this:
It helps to limit your lines to 80 positions or less. You may need
to break long statements with a
\at the end of a line. Also,
parenthesized expressions can be continued onto the next line without a \.
Some programmers will put in extra ()'s just to make line breaks
While spaces are used sparingly, they are always used to set off
comparison operators and boolean operators. Other mathmatical operators
may or may not be set off with spaces. This makes the comparisons stand
out in an
This shows the space around the comparison, but not the other