More installation info. Bump alpha version.
[python/dscho.git] / Doc / lib / libtypes.tex
blobadbec3b3382c06d1cfa0a4c0a6bdef1ae2915f2f
1 \section{\module{types} ---
2 Names for all built-in types}
4 \declaremodule{standard}{types}
5 \modulesynopsis{Names for all built-in types.}
8 This module defines names for all object types that are used by the
9 standard Python interpreter, but not for the types defined by various
10 extension modules. It is safe to use \samp{from types import *} ---
11 the module does not export any names besides the ones listed here.
12 New names exported by future versions of this module will all end in
13 \samp{Type}.
15 Typical use is for functions that do different things depending on
16 their argument types, like the following:
18 \begin{verbatim}
19 from types import *
20 def delete(list, item):
21 if type(item) is IntType:
22 del list[item]
23 else:
24 list.remove(item)
25 \end{verbatim}
27 The module defines the following names:
29 \begin{datadesc}{NoneType}
30 The type of \code{None}.
31 \end{datadesc}
33 \begin{datadesc}{TypeType}
34 The type of type objects (such as returned by
35 \function{type()}\bifuncindex{type}).
36 \end{datadesc}
38 \begin{datadesc}{BooleanType}
39 The type of the \class{bool} values \code{True} and \code{False}; this
40 is an alias of the built-in \function{bool()} function.
41 \versionadded{2.3}
42 \end{datadesc}
44 \begin{datadesc}{IntType}
45 The type of integers (e.g. \code{1}).
46 \end{datadesc}
48 \begin{datadesc}{LongType}
49 The type of long integers (e.g. \code{1L}).
50 \end{datadesc}
52 \begin{datadesc}{FloatType}
53 The type of floating point numbers (e.g. \code{1.0}).
54 \end{datadesc}
56 \begin{datadesc}{ComplexType}
57 The type of complex numbers (e.g. \code{1.0j}). This is not defined
58 if Python was built without complex number support.
59 \end{datadesc}
61 \begin{datadesc}{StringType}
62 The type of character strings (e.g. \code{'Spam'}).
63 \end{datadesc}
65 \begin{datadesc}{UnicodeType}
66 The type of Unicode character strings (e.g. \code{u'Spam'}). This is
67 not defined if Python was built without Unicode support.
68 \end{datadesc}
70 \begin{datadesc}{TupleType}
71 The type of tuples (e.g. \code{(1, 2, 3, 'Spam')}).
72 \end{datadesc}
74 \begin{datadesc}{ListType}
75 The type of lists (e.g. \code{[0, 1, 2, 3]}).
76 \end{datadesc}
78 \begin{datadesc}{DictType}
79 The type of dictionaries (e.g. \code{\{'Bacon': 1, 'Ham': 0\}}).
80 \end{datadesc}
82 \begin{datadesc}{DictionaryType}
83 An alternate name for \code{DictType}.
84 \end{datadesc}
86 \begin{datadesc}{FunctionType}
87 The type of user-defined functions and lambdas.
88 \end{datadesc}
90 \begin{datadesc}{LambdaType}
91 An alternate name for \code{FunctionType}.
92 \end{datadesc}
94 \begin{datadesc}{GeneratorType}
95 The type of generator-iterator objects, produced by calling a
96 generator function.
97 \versionadded{2.2}
98 \end{datadesc}
100 \begin{datadesc}{CodeType}
101 The type for code objects such as returned by
102 \function{compile()}\bifuncindex{compile}.
103 \end{datadesc}
105 \begin{datadesc}{ClassType}
106 The type of user-defined classes.
107 \end{datadesc}
109 \begin{datadesc}{InstanceType}
110 The type of instances of user-defined classes.
111 \end{datadesc}
113 \begin{datadesc}{MethodType}
114 The type of methods of user-defined class instances.
115 \end{datadesc}
117 \begin{datadesc}{UnboundMethodType}
118 An alternate name for \code{MethodType}.
119 \end{datadesc}
121 \begin{datadesc}{BuiltinFunctionType}
122 The type of built-in functions like \function{len()} or
123 \function{sys.exit()}.
124 \end{datadesc}
126 \begin{datadesc}{BuiltinMethodType}
127 An alternate name for \code{BuiltinFunction}.
128 \end{datadesc}
130 \begin{datadesc}{ModuleType}
131 The type of modules.
132 \end{datadesc}
134 \begin{datadesc}{FileType}
135 The type of open file objects such as \code{sys.stdout}.
136 \end{datadesc}
138 \begin{datadesc}{XRangeType}
139 The type of range objects returned by
140 \function{xrange()}\bifuncindex{xrange}.
141 \end{datadesc}
143 \begin{datadesc}{SliceType}
144 The type of objects returned by
145 \function{slice()}\bifuncindex{slice}.
146 \end{datadesc}
148 \begin{datadesc}{EllipsisType}
149 The type of \code{Ellipsis}.
150 \end{datadesc}
152 \begin{datadesc}{TracebackType}
153 The type of traceback objects such as found in
154 \code{sys.exc_traceback}.
155 \end{datadesc}
157 \begin{datadesc}{FrameType}
158 The type of frame objects such as found in \code{tb.tb_frame} if
159 \code{tb} is a traceback object.
160 \end{datadesc}
162 \begin{datadesc}{BufferType}
163 The type of buffer objects created by the
164 \function{buffer()}\bifuncindex{buffer} function.
165 \end{datadesc}
167 \begin{datadesc}{StringTypes}
168 A sequence containing \code{StringType} and \code{UnicodeType} used to
169 facilitate easier checking for any string object. Using this is more
170 portable than using a sequence of the two string types constructed
171 elsewhere since it only contains \code{UnicodeType} if it has been
172 built in the running version of Python. For example:
173 \code{isinstance(s, types.StringTypes)}.
174 \versionadded{2.2}
175 \end{datadesc}