[Tutor] Enumerate vs DictReader object manipulation:

Ben Finney ben+python at benfinney.id.au
Wed Feb 3 22:21:53 EST 2016


Alex Kleider <akleider at sonic.net> writes:

> How does a dict fit into this scheme?
> Is it a sequence?

No, a dict is not a sequence. But it is a container: all its items
remain available and can be retrieved again and again, and you can
interrogate whether a value is one of the items in that container.

An instance of the built-in ‘set’ type is also a container and not a
sequence.

Containers are iterable too.

> It is an iterable (in that for key in d: works although not in a
> predictable manner and for this reason I tend NOT to think of it as a
> sequence.)

That's right, IMO.

-- 
 \       “The generation of random numbers is too important to be left |
  `\                                    to chance.” —Robert R. Coveyou |
_o__)                                                                  |
Ben Finney



More information about the Tutor mailing list