6.1 Instantiating objectsA list of all of Pyxplot’s built-in object types can be found in the types module, which contains the object prototypes for each type. Its contents are as follows: pyxplot> print types These object prototypes can be called like functions to produce an instance of each data type. Each prototype can take various different kinds of argument; for example, the number prototype can take a number, boolean or a string from which to create a number. For example: pyxplot> types.number() Full documentation of the types of inputs supported by each prototype are listed in the Reference Manual, in Section 12.11. In many cases there are much more succinct ways of creating objects of each type. For example, lists can be creating by enclosing a comma-separated list of elements in square brackets: pyxplot> print [10,colors.green,"bottles"] Dictionaries can be can be creating by enclosing key–value pairs in curly brackets: pyxplot> s = {"name":"Sophie", "nationality":"British"}
|