Mercurial > cpython-lru_cache-weakref
annotate Doc/libtypes2.tex @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | f47bc5554418 |
| children | 3468ea8645ca |
| rev | line source |
|---|---|
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2462
diff
changeset
|
1 \section{Standard Module \sectcode{types}} |
| 2449 | 2 \stmodindex{types} |
| 3 | |
|
2462
e9e86ae5f5a4
small nits and new files
Guido van Rossum <guido@python.org>
parents:
2449
diff
changeset
|
4 \renewcommand{\indexsubitem}{(in module types)} |
|
e9e86ae5f5a4
small nits and new files
Guido van Rossum <guido@python.org>
parents:
2449
diff
changeset
|
5 |
| 2449 | 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 | |
|
2462
e9e86ae5f5a4
small nits and new files
Guido van Rossum <guido@python.org>
parents:
2449
diff
changeset
|
8 extension modules). It is safe to use ``\code{from types import *}'' --- |
| 2449 | 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}. | |
| 12 | |
| 13 Typical use is for functions that do different things depending on | |
| 14 their argument types, like the following: | |
| 15 | |
| 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} | |
| 24 | |
| 25 The module defines the following names: | |
| 26 | |
| 27 \begin{datadesc}{NoneType} | |
| 28 The type of \code{None}. | |
| 29 \end{datadesc} | |
| 30 | |
| 31 \begin{datadesc}{TypeType} | |
| 32 The type of type objects (such as returned by \code{type()}). | |
| 33 \end{datadesc} | |
| 34 | |
| 35 \begin{datadesc}{IntType} | |
| 36 The type of integers (e.g. \code{1}). | |
| 37 \end{datadesc} | |
| 38 | |
| 39 \begin{datadesc}{LongType} | |
| 40 The type of long integers (e.g. \code{1L}). | |
| 41 \end{datadesc} | |
| 42 | |
| 43 \begin{datadesc}{FloatType} | |
| 44 The type of floating point numbers (e.g. \code{1.0}). | |
| 45 \end{datadesc} | |
| 46 | |
| 47 \begin{datadesc}{StringType} | |
| 48 The type of character strings (e.g. \code{'Spam'}). | |
| 49 \end{datadesc} | |
| 50 | |
| 51 \begin{datadesc}{TupleType} | |
| 52 The type of tuples (e.g. \code{(1, 2, 3, 'Spam')}). | |
| 53 \end{datadesc} | |
| 54 | |
| 55 \begin{datadesc}{ListType} | |
| 56 The type of lists (e.g. \code{[0, 1, 2, 3]}). | |
| 57 \end{datadesc} | |
| 58 | |
| 59 \begin{datadesc}{DictType} | |
| 60 The type of dictionaries (e.g. \code{\{'Bacon': 1, 'Ham': 0\}}). | |
| 61 \end{datadesc} | |
| 62 | |
| 63 \begin{datadesc}{DictionaryType} | |
| 64 An alternative name for \code{DictType}. | |
| 65 \end{datadesc} | |
| 66 | |
| 67 \begin{datadesc}{FunctionType} | |
| 68 The type of user-defined functions and lambdas. | |
| 69 \end{datadesc} | |
| 70 | |
| 71 \begin{datadesc}{LambdaType} | |
| 72 An alternative name for \code{FunctionType}. | |
| 73 \end{datadesc} | |
| 74 | |
| 75 \begin{datadesc}{CodeType} | |
| 76 The type for code objects such as returned by \code{compile()}. | |
| 77 \end{datadesc} | |
| 78 | |
| 79 \begin{datadesc}{ClassType} | |
| 80 The type of user-defined classes. | |
| 81 \end{datadesc} | |
| 82 | |
| 83 \begin{datadesc}{InstanceType} | |
| 84 The type of instances of user-defined classes. | |
| 85 \end{datadesc} | |
| 86 | |
| 87 \begin{datadesc}{MethodType} | |
| 88 The type of methods of user-defined class instances. | |
| 89 \end{datadesc} | |
| 90 | |
| 91 \begin{datadesc}{UnboundMethodType} | |
| 92 An alternative name for \code{MethodType}. | |
| 93 \end{datadesc} | |
| 94 | |
| 95 \begin{datadesc}{BuiltinFunctionType} | |
| 96 The type of built-in functions like \code{len} or \code{sys.exit}. | |
| 97 \end{datadesc} | |
| 98 | |
| 99 \begin{datadesc}{BuiltinMethodType} | |
| 100 An alternative name for \code{BuiltinFunction}. | |
| 101 \end{datadesc} | |
| 102 | |
| 103 \begin{datadesc}{ModuleType} | |
| 104 The type of modules. | |
| 105 \end{datadesc} | |
| 106 | |
| 107 \begin{datadesc}{FileType} | |
| 108 The type of open file objects such as \code{sys.stdout}. | |
| 109 \end{datadesc} | |
| 110 | |
| 111 \begin{datadesc}{XRangeType} | |
| 112 The type of range objects returned by \code{xrange()}. | |
| 113 \end{datadesc} | |
| 114 | |
| 115 \begin{datadesc}{TracebackType} | |
| 116 The type of traceback objects such as found in \code{sys.exc_traceback}. | |
| 117 \end{datadesc} | |
| 118 | |
| 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} |
