arrows pointing right and left

Programming Types

email Scott Turner

precise, logical types

termdescriptionPython typePython expressions*
primitive types
booleanint1, 0, 1==0
integerint,long0, 1, 2, -1
floating pointfloat2.718, -1.0
stringstring"3 is the best number!"
nonetrivial type with just 1 valueNoneNone
voidtype with no valuesNonemylist.append(123)
the indiscriminate typeinput: function from string to action returning the indiscriminate type
derived types
tuple of            ("hello", "my", "name", "is", "Phil", "."): tuple of string
(11, 16, 18, 50, 52): tuple of integer
list of            ["hello", "my", "name", "is", "Phil", "."]: list of string
[11, 16, 18, 50, 52]: list of integer
function from             to            string.atoi: function from string to integer
car: for all t, function from list of t to t
action returning            put-newline: action returning the trivial type
random.choice: for all e, function from (list of e) to action returning e
            and            subst: for all t, function from (t and t and (list of t)) to (list of t)
            or            talky: function from the indiscriminate type to (boolean or the trivial type)
quantified types
for all type-parameter,            cons: for all t, function from (t and (list of t)) to (list of t)
*: some of the later examples are of Scheme functions rather than Python.

Support open standards!  
Valid XHTML 1.0!