Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions

  




 

 

Chapter 14. Lists

We'll look at lists from a number of viewpoints: semantics, literal values, operations, comparison operators, statements, built-in functions and methods. Additionally, we have a digression on the immutability of strings.

List Semantics

A list is a container for variable length sequence of Python objects. A list is mutable, which means that items within the list can be changed. Also, items can be added to the list or removed from the list.

A list is an mutable sequence of Python objects. Since it is a sequence, all of the common operations to sequences apply. Since it is mutable, it can be changed: objects can be added to, removed from and replaced in a list.

Sometimes we'll see a list with a fixed number of elements, like a two-dimensional point with two elements, x and y . When someone asks about a fixed-length list, we have to remind them that the tuple, covered in Chapter 14, Lists , is for static sequences of elements.

A great deal of Python's internals a list-based. The for statement, in particular, expects a sequence, and we often create a list by using the range function. When we split a string using the split method, we get a list of substrings.


 
 
  Published under the terms of the Open Publication License Design by Interspire