What exactly are "containers" in python? (And what are all the python container types?)

Viewed 65519

The python documentation frequently speaks of "containers". E.g. :

If check_circular is False (default: True), then the circular reference check for container types will be skipped and a circular reference will result in an OverflowError (or worse).

But I can't find any official definition of containers, neither a list of them.

Edit

For Python 2.7.3:

Checked builtin types which are containers:

(isinstance(object, collections.Container) returns True)

  1. Containers which have a __contains__ method defined:

    • All builtin sequence types: Lists, bytearrays, strings, unicode strings and tuples.
    • Dictionaries
    • All builtin set types: sets and frozensets
  2. Containers which do not have a __contains__ method defined:

    • xrange objects

Checked builtin types which are not containers:

(isinstance(object, collections.Container) returns False):

  • Int objects
  • Float objects
  • Long objects
  • Boolean objects
  • Module objects
  • File objects
  • Buffer objects
  • The None object

Tell me which other builtin types you have checked for isinstance(object, collections.Container) and I'll add them to the list.

3 Answers
Related