(py-indent-right, py-outdent-left): new commands, bound to C-c C-r and
[python/dscho.git] / Doc / libtypes2.tex
blob2280ed7e0b0f88dbf30617086aaac32b4c514d7d
1 \section{Built-in module \sectcode{types}}
2 \stmodindex{types}
4 \renewcommand{\indexsubitem}{(in module types)}
6 This module defines names for all object types that are used by the
7 standard Python interpreter (but not for the types defined by various
8 extension modules). It is safe to use ``\code{from types import *}'' ---
9 the module does not export any other names besides the ones listed
10 here. New names exported by future versions of this module will
11 all end in \code{Type}.
13 Typical use is for functions that do different things depending on
14 their argument types, like the following:
16 \begin{verbatim}
17 from types import *
18 def delete(list, item):
19 if type(item) is IntType:
20 del list[item]
21 else:
22 list.remove(item)
23 \end{verbatim}
25 The module defines the following names:
27 \begin{datadesc}{NoneType}
28 The type of \code{None}.
29 \end{datadesc}
31 \begin{datadesc}{TypeType}
32 The type of type objects (such as returned by \code{type()}).
33 \end{datadesc}
35 \begin{datadesc}{IntType}
36 The type of integers (e.g. \code{1}).
37 \end{datadesc}
39 \begin{datadesc}{LongType}
40 The type of long integers (e.g. \code{1L}).
41 \end{datadesc}
43 \begin{datadesc}{FloatType}
44 The type of floating point numbers (e.g. \code{1.0}).
45 \end{datadesc}
47 \begin{datadesc}{StringType}
48 The type of character strings (e.g. \code{'Spam'}).
49 \end{datadesc}
51 \begin{datadesc}{TupleType}
52 The type of tuples (e.g. \code{(1, 2, 3, 'Spam')}).
53 \end{datadesc}
55 \begin{datadesc}{ListType}
56 The type of lists (e.g. \code{[0, 1, 2, 3]}).
57 \end{datadesc}
59 \begin{datadesc}{DictType}
60 The type of dictionaries (e.g. \code{\{'Bacon': 1, 'Ham': 0\}}).
61 \end{datadesc}
63 \begin{datadesc}{DictionaryType}
64 An alternative name for \code{DictType}.
65 \end{datadesc}
67 \begin{datadesc}{FunctionType}
68 The type of user-defined functions and lambdas.
69 \end{datadesc}
71 \begin{datadesc}{LambdaType}
72 An alternative name for \code{FunctionType}.
73 \end{datadesc}
75 \begin{datadesc}{CodeType}
76 The type for code objects such as returned by \code{compile()}.
77 \end{datadesc}
79 \begin{datadesc}{ClassType}
80 The type of user-defined classes.
81 \end{datadesc}
83 \begin{datadesc}{InstanceType}
84 The type of instances of user-defined classes.
85 \end{datadesc}
87 \begin{datadesc}{MethodType}
88 The type of methods of user-defined class instances.
89 \end{datadesc}
91 \begin{datadesc}{UnboundMethodType}
92 An alternative name for \code{MethodType}.
93 \end{datadesc}
95 \begin{datadesc}{BuiltinFunctionType}
96 The type of built-in functions like \code{len} or \code{sys.exit}.
97 \end{datadesc}
99 \begin{datadesc}{BuiltinMethodType}
100 An alternative name for \code{BuiltinFunction}.
101 \end{datadesc}
103 \begin{datadesc}{ModuleType}
104 The type of modules.
105 \end{datadesc}
107 \begin{datadesc}{FileType}
108 The type of open file objects such as \code{sys.stdout}.
109 \end{datadesc}
111 \begin{datadesc}{XRangeType}
112 The type of range objects returned by \code{xrange()}.
113 \end{datadesc}
115 \begin{datadesc}{TracebackType}
116 The type of traceback objects such as found in \code{sys.exc_traceback}.
117 \end{datadesc}
119 \begin{datadesc}{FrameType}
120 The type of frame objects such as found in \code{tb.tb_frame} if
121 \code{tb} is a traceback object.
122 \end{datadesc}