First page Back Continue Last page Overview Graphics

Dictionaries

Dictionaries are sometimes found in other languages as “associative arrays” or “hashes” in Perl.

Dictionaries can be thought of as unordered sets of (key,value)-pairs.

Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type, i.e. strings and numbers can always be keys.

Tuples can be used as keys if they contain only strings, numbers, or tuples.

If a tuple contains any mutable object either directly or indirectly, it cannot be used as a key.