Datasheet

Chapter 1: A Python Primer
4
The keywords are as follows:
and del for is raise
assert elif from lambda return
break else global not try
class except if or while
continue exec import pass
def finally in print yield
Lines and Indentation
In Python, unlike a compiled language such as C, line breaks are significant, and the end of a program
statement is defined by a hard return. Program blocks are defined by a combination of statements (each
on a separate line, but with no end - of - statement character visible) and program blocks, delimited
visually by the use of indentation.
As shown in the code from the preceding section, lines are indented in Python. This is not simply a
stylistic choice indentation is not just recommended in Python, but enforced by the interpreter. This is
probably the most controversial aspect of Python, and it has been the subject of many a flame war online.
Basically, it means that the following code would generate an interpreter error, because the action
associated with an
if statement must be indented:
if variable1 == “Jim”:
print “variable1 eqiuals Jim”
You ll learn more about the actual if statement itself later.
Data Types and Identifiers
Python provides a rich collection of data types to enable programmers to perform virtually any
programming task they desire in another language. One nice thing about Python is that it provides many
useful and unique data types (such as tuples and dictionaries), and stays away from data types such as
the pointers used in C, which have their use but can also make programming much more confusing and
difficult for the nonprofessional programmer.
c01.indd 4c01.indd 4 6/2/08 12:03:08 PM6/2/08 12:03:08 PM