June 2000
Intermediate to advanced
556 pages
8h 45m
English
The pass statement provides a way of saying “do nothing” that can be very useful during program development. For example, you want to lay out an if statement in which you have not yet filled in one of the branches but you want to be able to execute the program:
CD-ROM reference=6046.txt
if x > y:
x = x - 1
elif x == y:
# XXX deal with this case later.
pass
else:
print "Hello World"
The pass statement is also used with methods as a way of indicating that the method should be overridden by a subclass to do something useful. This idea is used heavily in the SAX API, which we discuss in chapter 10.
CD-ROM reference=6047.txt class DocumentHandler: def characters(str): # Override this method to do something useful. pass ...
Read now
Unlock full access