Mappings

  • A set of items indexed by arbitrary values.
  • The built-in function len() returns the number of items in a mapping.

Dictionaries

{ key : value [, key : value]* }
  • Comma-separated, brace-enclosed list of key : value pairs.
  • Dictionaries are mutable (writeable).
  • The indexes cannot contain lists or dictionaries or other mutable types that are compared by value rather than by object identity.
  • Numeric indexes obey the normal rules for numeric comparison (i.e. 1 is equivalent to 1.0).
{}                 # 0 items
{1:'a'} # 1 item
{1:'a', 'two':'b'} # 2 items