December 2000
Intermediate to advanced
816 pages
16h 57m
English
The type() built-in function, when operated on a dictionary, reveals an object of the dictionary type. The str() built-in function will produce a printable string representation of a dictionary. These are fairly straightfoward.
In each of the last three chapters, we showed how the cmp() built-in function worked with numbers, strings, lists, and tuples. So how about dictionaries? Comparisons of dictionaries are based on an algorithm which starts with sizes first, then keys, and finally values. In our example below, we create two dictionaries and compare them, then slowly modify the dictionaries to show how these changes affect their comparisons:
>>> dict1 = {} ...Read now
Unlock full access