Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

3. Collections

Chapter 3. Collections

Instances of primitive Python types represent individual values, as we saw in the first chapter. Python also has built-in types that are compound, meaning that they group together multiple objects. These are called collections or containers. The objects in a collection are generally referred to as items or elements. Collections can hold any number of items. Some collection types can even contain items with a mixture of types, including other collections.

There are three categories of built-in collection types in Python: sets, sequences, and mappings. Streams are another kind of collection whose elements form a series in time, rather than the computer’s memory space. Though they are not formally recognized in Python, many of Python’s functions and methods—especially those that manipulate files—implement stream-like behavior. Modules such as array and collections provide additional collection types.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint