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()
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 13, which also lists the methods available in each object type.