December 2000
Intermediate to advanced
816 pages
16h 57m
English
Dictionaries do not support sequence operations such as concatenation and repetition, although an update() built-in method exists that populates one dictionary with the contents of another. Dictionaries do not have a “membership” operator either, but the has_key() built-in method basically performs the same task.
Dictionaries will work with all of the standard type operators. These were introduced in Chapter 4, but we will present some examples of how to use them with dictionaries here:
>>> dict4 = { 'abc': 123 }
>>> dict5 = { 'abc': 456 }
>>> dict6 = { 'abc': 123, 98.6: 37 }
>>> dict7 = { 'xyz': 123 }
>>> dict4 < dict5
1
>>> (dict4 < dict6) and (dict4 < dict7)
1
>>> (dict5 < dict6) and (dict5 ...Read now
Unlock full access