# cpython-withatomic / Doc / libtypes2.tex

The branch 'legacy-trunk' does not exist.
  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 \section{Standard Module \sectcode{types}} \label{module-types} \stmodindex{types} \renewcommand{\indexsubitem}{(in module types)} This module defines names for all object types that are used by the standard Python interpreter (but not for the types defined by various extension modules). It is safe to use \code{from types import *}'' --- the module does not export any other names besides the ones listed here. New names exported by future versions of this module will all end in \code{Type}. Typical use is for functions that do different things depending on their argument types, like the following: \bcode\begin{verbatim} from types import * def delete(list, item): if type(item) is IntType: del list[item] else: list.remove(item) \end{verbatim}\ecode % The module defines the following names: \begin{datadesc}{NoneType} The type of \code{None}. \end{datadesc} \begin{datadesc}{TypeType} The type of type objects (such as returned by \code{type()}). \end{datadesc} \begin{datadesc}{IntType} The type of integers (e.g. \code{1}). \end{datadesc} \begin{datadesc}{LongType} The type of long integers (e.g. \code{1L}). \end{datadesc} \begin{datadesc}{FloatType} The type of floating point numbers (e.g. \code{1.0}). \end{datadesc} \begin{datadesc}{StringType} The type of character strings (e.g. \code{'Spam'}). \end{datadesc} \begin{datadesc}{TupleType} The type of tuples (e.g. \code{(1, 2, 3, 'Spam')}). \end{datadesc} \begin{datadesc}{ListType} The type of lists (e.g. \code{[0, 1, 2, 3]}). \end{datadesc} \begin{datadesc}{DictType} The type of dictionaries (e.g. \code{\{'Bacon': 1, 'Ham': 0\}}). \end{datadesc} \begin{datadesc}{DictionaryType} An alternative name for \code{DictType}. \end{datadesc} \begin{datadesc}{FunctionType} The type of user-defined functions and lambdas. \end{datadesc} \begin{datadesc}{LambdaType} An alternative name for \code{FunctionType}. \end{datadesc} \begin{datadesc}{CodeType} The type for code objects such as returned by \code{compile()}. \end{datadesc} \begin{datadesc}{ClassType} The type of user-defined classes. \end{datadesc} \begin{datadesc}{InstanceType} The type of instances of user-defined classes. \end{datadesc} \begin{datadesc}{MethodType} The type of methods of user-defined class instances. \end{datadesc} \begin{datadesc}{UnboundMethodType} An alternative name for \code{MethodType}. \end{datadesc} \begin{datadesc}{BuiltinFunctionType} The type of built-in functions like \code{len} or \code{sys.exit}. \end{datadesc} \begin{datadesc}{BuiltinMethodType} An alternative name for \code{BuiltinFunction}. \end{datadesc} \begin{datadesc}{ModuleType} The type of modules. \end{datadesc} \begin{datadesc}{FileType} The type of open file objects such as \code{sys.stdout}. \end{datadesc} \begin{datadesc}{XRangeType} The type of range objects returned by \code{xrange()}. \end{datadesc} \begin{datadesc}{TracebackType} The type of traceback objects such as found in \code{sys.exc_traceback}. \end{datadesc} \begin{datadesc}{FrameType} The type of frame objects such as found in \code{tb.tb_frame} if \code{tb} is a traceback object. \end{datadesc} 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.