rest25/library/types.rst => rest262/library/types.rst
n1- 
2:mod:`types` --- Names for built-in types
3=========================================
4
5.. module:: types
6   :synopsis: Names for built-in types.
7
8
9This module defines names for some object types that are used by the standard
41
42   The type of ``None``.
43
44
45.. data:: TypeType
46
47   .. index:: builtin: type
48
n49-   The type of type objects (such as returned by :func:`type`).
n48+   The type of type objects (such as returned by :func:`type`); alias of the
49+   built-in :class:`type`.
50
51
52.. data:: BooleanType
53
n54-   The type of the :class:`bool` values ``True`` and ``False``; this is an alias of
n54+   The type of the :class:`bool` values ``True`` and ``False``; alias of the
55-   the built-in :func:`bool` function.
55+   built-in :class:`bool`.
56
57   .. versionadded:: 2.3
58
59
60.. data:: IntType
61
n62-   The type of integers (e.g. ``1``).
n62+   The type of integers (e.g. ``1``); alias of the built-in :class:`int`.
63
64
65.. data:: LongType
66
n67-   The type of long integers (e.g. ``1L``).
n67+   The type of long integers (e.g. ``1L``); alias of the built-in :class:`long`.
68
69
70.. data:: FloatType
71
n72-   The type of floating point numbers (e.g. ``1.0``).
n72+   The type of floating point numbers (e.g. ``1.0``); alias of the built-in
73+   :class:`float`.
73
74
75.. data:: ComplexType
76
77   The type of complex numbers (e.g. ``1.0j``).  This is not defined if Python was
78   built without complex number support.
79
80
81.. data:: StringType
82
n83-   The type of character strings (e.g. ``'Spam'``).
n84+   The type of character strings (e.g. ``'Spam'``); alias of the built-in
85+   :class:`str`.
84
85
86.. data:: UnicodeType
87
88   The type of Unicode character strings (e.g. ``u'Spam'``).  This is not defined
n89-   if Python was built without Unicode support.
n91+   if Python was built without Unicode support.  It's an alias of the built-in
92+   :class:`unicode`.
90
91
92.. data:: TupleType
93
n94-   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``).
n97+   The type of tuples (e.g. ``(1, 2, 3, 'Spam')``); alias of the built-in
98+   :class:`tuple`.
95
96
97.. data:: ListType
98
n99-   The type of lists (e.g. ``[0, 1, 2, 3]``).
n103+   The type of lists (e.g. ``[0, 1, 2, 3]``); alias of the built-in
104+   :class:`list`.
100
101
102.. data:: DictType
103
n104-   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``).
n109+   The type of dictionaries (e.g. ``{'Bacon': 1, 'Ham': 0}``); alias of the
110+   built-in :class:`dict`.
105
106
107.. data:: DictionaryType
108
109   An alternate name for ``DictType``.
110
111
112.. data:: FunctionType
n119+          LambdaType
113
n114-   The type of user-defined functions and lambdas.
n121+   The type of user-defined functions and functions created by :keyword:`lambda`
115- 
122+   expressions.
116- 
117-.. data:: LambdaType
118- 
119-   An alternate name for ``FunctionType``.
120
121
122.. data:: GeneratorType
123
n124-   The type of generator-iterator objects, produced by calling a generator
n127+   The type of :term:`generator`-iterator objects, produced by calling a
125-   function.
128+   generator function.
126
127   .. versionadded:: 2.2
128
129
130.. data:: CodeType
131
132   .. index:: builtin: compile
133
134   The type for code objects such as returned by :func:`compile`.
135
136
137.. data:: ClassType
138
n139-   The type of user-defined classes.
n142+   The type of user-defined old-style classes.
140
141
142.. data:: InstanceType
143
144   The type of instances of user-defined classes.
145
146
147.. data:: MethodType
150
151
152.. data:: UnboundMethodType
153
154   An alternate name for ``MethodType``.
155
156
157.. data:: BuiltinFunctionType
n161+          BuiltinMethodType
158
n159-   The type of built-in functions like :func:`len` or :func:`sys.exit`.
n163+   The type of built-in functions like :func:`len` or :func:`sys.exit`, and
160- 
164+   methods of built-in classes.  (Here, the term "built-in" means "written in
161- 
165+   C".)
162-.. data:: BuiltinMethodType
163- 
164-   An alternate name for ``BuiltinFunction``.
165
166
167.. data:: ModuleType
168
169   The type of modules.
170
171
172.. data:: FileType
173
n174-   The type of open file objects such as ``sys.stdout``.
n175+   The type of open file objects such as ``sys.stdout``; alias of the built-in
176+   :class:`file`.
175
176
177.. data:: XRangeType
178
179   .. index:: builtin: xrange
180
n181-   The type of range objects returned by :func:`xrange`.
n183+   The type of range objects returned by :func:`xrange`; alias of the built-in
184+   :class:`xrange`.
182
183
184.. data:: SliceType
185
186   .. index:: builtin: slice
187
n188-   The type of objects returned by :func:`slice`.
n191+   The type of objects returned by :func:`slice`; alias of the built-in
192+   :class:`slice`.
189
190
191.. data:: EllipsisType
192
193   The type of ``Ellipsis``.
194
195
196.. data:: TracebackType
218
219.. data:: NotImplementedType
220
221   The type of ``NotImplemented``
222
223
224.. data:: GetSetDescriptorType
225
n226-   The type of objects defined in extension modules with ``PyGetSetDef``, such as
n230+   The type of objects defined in extension modules with ``PyGetSetDef``, such
227-   ``FrameType.f_locals`` or ``array.array.typecode``.  This constant is not
231+   as ``FrameType.f_locals`` or ``array.array.typecode``.  This type is used as
228-   defined in implementations of Python that do not have such extension types, so
232+   descriptor for object attributes; it has the same purpose as the
229-   for portable code use ``hasattr(types, 'GetSetDescriptorType')``.
233+   :class:`property` type, but for classes defined in extension modules.
230
231   .. versionadded:: 2.5
232
233
234.. data:: MemberDescriptorType
235
n236-   The type of objects defined in extension modules with ``PyMemberDef``, such as
n240+   The type of objects defined in extension modules with ``PyMemberDef``, such
237-   ``datetime.timedelta.days``.  This constant is not defined in implementations of
241+   as ``datetime.timedelta.days``.  This type is used as descriptor for simple C
238-   Python that do not have such extension types, so for portable code use
242+   data members which use standard conversion functions; it has the same purpose
239-   ``hasattr(types, 'MemberDescriptorType')``.
243+   as the :class:`property` type, but for classes defined in extension modules.
244+   In other implementations of Python, this type may be identical to
245+   ``GetSetDescriptorType``.
240
241   .. versionadded:: 2.5
242
243
244.. data:: StringTypes
245
246   A sequence containing ``StringType`` and ``UnicodeType`` used to facilitate
247   easier checking for any string object.  Using this is more portable than using a
248   sequence of the two string types constructed elsewhere since it only contains
249   ``UnicodeType`` if it has been built in the running version of Python.  For
250   example: ``isinstance(s, types.StringTypes)``.
251
252   .. versionadded:: 2.2
t253- 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op