Added 'list_only' option (and modified 'run()' to respect it).
[python/dscho.git] / Doc / lib / libtypes.tex
blob5f9034c3e17e93740fca652cd23fc4311f4faaee
1 \section{\module{types} ---
2 Names for all built-in types.}
3 \declaremodule{standard}{types}
5 \modulesynopsis{Names for all built-in types.}
9 This module defines names for all object types that are used by the
10 standard Python interpreter, but not for the types defined by various
11 extension modules. It is safe to use \samp{from types import *} ---
12 the module does not export any names besides the ones listed here.
13 New names exported by future versions of this module will all end in
14 \samp{Type}.
16 Typical use is for functions that do different things depending on
17 their argument types, like the following:
19 \begin{verbatim}
20 from types import *
21 def delete(list, item):
22 if type(item) is IntType:
23 del list[item]
24 else:
25 list.remove(item)
26 \end{verbatim}
28 The module defines the following names:
30 \begin{datadesc}{NoneType}
31 The type of \code{None}.
32 \end{datadesc}
34 \begin{datadesc}{TypeType}
35 The type of type objects (such as returned by
36 \function{type()}\bifuncindex{type}).
37 \end{datadesc}
39 \begin{datadesc}{IntType}
40 The type of integers (e.g. \code{1}).
41 \end{datadesc}
43 \begin{datadesc}{LongType}
44 The type of long integers (e.g. \code{1L}).
45 \end{datadesc}
47 \begin{datadesc}{FloatType}
48 The type of floating point numbers (e.g. \code{1.0}).
49 \end{datadesc}
51 \begin{datadesc}{ComplexType}
52 The type of complex numbers (e.g. \code{1.0j}).
53 \end{datadesc}
55 \begin{datadesc}{StringType}
56 The type of character strings (e.g. \code{'Spam'}).
57 \end{datadesc}
59 \begin{datadesc}{TupleType}
60 The type of tuples (e.g. \code{(1, 2, 3, 'Spam')}).
61 \end{datadesc}
63 \begin{datadesc}{ListType}
64 The type of lists (e.g. \code{[0, 1, 2, 3]}).
65 \end{datadesc}
67 \begin{datadesc}{DictType}
68 The type of dictionaries (e.g. \code{\{'Bacon': 1, 'Ham': 0\}}).
69 \end{datadesc}
71 \begin{datadesc}{DictionaryType}
72 An alternate name for \code{DictType}.
73 \end{datadesc}
75 \begin{datadesc}{FunctionType}
76 The type of user-defined functions and lambdas.
77 \end{datadesc}
79 \begin{datadesc}{LambdaType}
80 An alternate name for \code{FunctionType}.
81 \end{datadesc}
83 \begin{datadesc}{CodeType}
84 The type for code objects such as returned by
85 \function{compile()}\bifuncindex{compile}.
86 \end{datadesc}
88 \begin{datadesc}{ClassType}
89 The type of user-defined classes.
90 \end{datadesc}
92 \begin{datadesc}{InstanceType}
93 The type of instances of user-defined classes.
94 \end{datadesc}
96 \begin{datadesc}{MethodType}
97 The type of methods of user-defined class instances.
98 \end{datadesc}
100 \begin{datadesc}{UnboundMethodType}
101 An alternate name for \code{MethodType}.
102 \end{datadesc}
104 \begin{datadesc}{BuiltinFunctionType}
105 The type of built-in functions like \function{len()} or
106 \function{sys.exit()}.
107 \end{datadesc}
109 \begin{datadesc}{BuiltinMethodType}
110 An alternate name for \code{BuiltinFunction}.
111 \end{datadesc}
113 \begin{datadesc}{ModuleType}
114 The type of modules.
115 \end{datadesc}
117 \begin{datadesc}{FileType}
118 The type of open file objects such as \code{sys.stdout}.
119 \end{datadesc}
121 \begin{datadesc}{XRangeType}
122 The type of range objects returned by
123 \function{xrange()}\bifuncindex{xrange}.
124 \end{datadesc}
126 \begin{datadesc}{SliceType}
127 The type of objects returned by
128 \function{slice()}\bifuncindex{slice}.
129 \end{datadesc}
131 \begin{datadesc}{EllipsisType}
132 The type of \code{Ellipsis}.
133 \end{datadesc}
135 \begin{datadesc}{TracebackType}
136 The type of traceback objects such as found in
137 \code{sys.exc_traceback}.
138 \end{datadesc}
140 \begin{datadesc}{FrameType}
141 The type of frame objects such as found in \code{tb.tb_frame} if
142 \code{tb} is a traceback object.
143 \end{datadesc}