# 6 Programming: Pyxplot’s data types

This chapter describes Pyxplot’s built-in object types, which include lists, dictionaries, vectors, matrices and file handles.

All objects in Pyxplot, including numbers, have methods, which act on or return information about the object. Some methods are common to all objects. For example, they all have a method `str()` which returns a string representation of the object (as used by the `print` command). All objects also have a method called `methods()`, which returns a list of the names of all of methods of that object. These methods can be called as follows (we don’t show the output, as it is long):

    print pi.str()
    print "My son, it's a wisp of fog.".methods()

Methods are like functions in that printing them returns brief documentation about them, as we demonstrate below on two methods of string objects:

`pyxplot> print "Father, do you not see the Elfking?".upper`
`upper() converts a string to uppercase.`
`pyxplot> print "Father, do you not see the Elfking?".upper()`
`FATHER, DO YOU NOT SEE THE ELFKING?`
`pyxplot> print "Father, do you not see the Elfking?".methods`
`methods() returns a list of the methods of an object.`

The following sections describe each of Pyxplot’s types in turn, and the methods that can be applied to each of them. A comprehensive list of all of Pyxplot’s object types can be found in Chapter , which also lists the methods available in each object type.

- 6.1 Instantiating objects
- 6.2 Strings
  - 6.2.1 The string substitution operator
  - 6.2.2 Converting strings to numbers
  - 6.2.3 Slicing strings
  - 6.2.4 String methods
  - 6.2.5 Regular expressions
- 6.3 Lists
  - 6.3.1 Using lists as stacks
  - 6.3.2 Using lists as buffers
  - 6.3.3 Sorting lists
  - 6.3.4 Iterating over lists
  - 6.3.5 Calling functions with lists of arguments
  - 6.3.6 List mapping and filtering
  - 6.3.7 Vectors versus lists
- 6.4 Dictionaries
- 6.5 Vectors and matrices
  - 6.5.1 Dot and cross products
  - 6.5.2 Matrix algebra
  - 6.5.3 Plotting data from vectors
- 6.6 Colors
  - 6.6.1 Color representations of the electromagnetic spectrum
- 6.7 Dates
- 6.8 Modules and classes
- 6.9 File handles
  - 6.9.1 Storing data structures in text files