June 2000
Intermediate to advanced
556 pages
8h 45m
English
None is a special object in Python used to signify the absence of a value. It pops up all over the place in Python. It is the value automatically returned by a function or method unless you specify otherwise. The existence of None gets nicely around an ambiguity found in languages with no such concept. This is best illustrated by example.
In the following code snippet, the empty string and the number 0 are used to mean “Surname does not exist” and “No such account holder,” respectively.
CD-ROM reference=6026.txt
x = getSurname("Sean")
if x == "":
print "Surname does not exist"
balance = getBalance("Sean")
if balance == 0:
print "No such account holder"
In the getSurname case, the use of an empty string to ...
Read now
Unlock full access