<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>3.2 types --
Names for all built-in types.</TITLE>
<META NAME="description" CONTENT="3.2 types --
Names for all built-in types.">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="next" HREF="module-UserDict.html">
<LINK REL="previous" HREF="module-sys.html">
<LINK REL="up" HREF="python.html">
<LINK REL="next" HREF="module-UserDict.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-UserDict.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="python.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-sys.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-UserDict.html">3.3 UserDict  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="python.html">3. Python Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-sys.html">3.1 sys  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION005200000000000000000">
3.2 <tt class=module>types</tt> --
         Names for all built-in types.</A>
</H1>

<P>

<P>
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 "<tt class=samp>from types import *</tt>" --
the module does not export any names besides the ones listed here.
New names exported by future versions of this module will all end in
"<tt class=samp>Type</tt>".

<P>
Typical use is for functions that do different things depending on
their argument types, like the following:

<P>
<dl><dd><pre class=verbatim>
from types import *
def delete(list, item):
    if type(item) is IntType:
       del list[item]
    else:
       list.remove(item)
</pre></dl>

<P>
The module defines the following names:

<P>
<dl><dt><b><a name="l2h-290"><tt>NoneType</tt></a></b>
<dd>
The type of <tt>None</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-291"><tt>TypeType</tt></a></b>
<dd>
The type of type objects (such as returned by
<tt class=function>type()</tt><a name="l2h-317"></a>).
</dl>

<P>
<dl><dt><b><a name="l2h-292"><tt>IntType</tt></a></b>
<dd>
The type of integers (e.g. <tt>1</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-293"><tt>LongType</tt></a></b>
<dd>
The type of long integers (e.g. <tt>1L</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-294"><tt>FloatType</tt></a></b>
<dd>
The type of floating point numbers (e.g. <tt>1.0</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-295"><tt>ComplexType</tt></a></b>
<dd>
The type of complex numbers (e.g. <tt>1.0j</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-296"><tt>StringType</tt></a></b>
<dd>
The type of character strings (e.g. <tt>'Spam'</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-297"><tt>TupleType</tt></a></b>
<dd>
The type of tuples (e.g. <tt>(1, 2, 3, 'Spam')</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-298"><tt>ListType</tt></a></b>
<dd>
The type of lists (e.g. <tt>[0, 1, 2, 3]</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-299"><tt>DictType</tt></a></b>
<dd>
The type of dictionaries (e.g. <tt>{'Bacon': 1, 'Ham': 0}</tt>).
</dl>

<P>
<dl><dt><b><a name="l2h-300"><tt>DictionaryType</tt></a></b>
<dd>
An alternate name for <tt>DictType</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-301"><tt>FunctionType</tt></a></b>
<dd>
The type of user-defined functions and lambdas.
</dl>

<P>
<dl><dt><b><a name="l2h-302"><tt>LambdaType</tt></a></b>
<dd>
An alternate name for <tt>FunctionType</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-303"><tt>CodeType</tt></a></b>
<dd>
The type for code objects such as returned by
<tt class=function>compile()</tt><a name="l2h-318"></a>.
</dl>

<P>
<dl><dt><b><a name="l2h-304"><tt>ClassType</tt></a></b>
<dd>
The type of user-defined classes.
</dl>

<P>
<dl><dt><b><a name="l2h-305"><tt>InstanceType</tt></a></b>
<dd>
The type of instances of user-defined classes.
</dl>

<P>
<dl><dt><b><a name="l2h-306"><tt>MethodType</tt></a></b>
<dd>
The type of methods of user-defined class instances.
</dl>

<P>
<dl><dt><b><a name="l2h-307"><tt>UnboundMethodType</tt></a></b>
<dd>
An alternate name for <tt>MethodType</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-308"><tt>BuiltinFunctionType</tt></a></b>
<dd>
The type of built-in functions like <tt class=function>len()</tt> or
<tt class=function>sys.exit()</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-309"><tt>BuiltinMethodType</tt></a></b>
<dd>
An alternate name for <tt>BuiltinFunction</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-310"><tt>ModuleType</tt></a></b>
<dd>
The type of modules.
</dl>

<P>
<dl><dt><b><a name="l2h-311"><tt>FileType</tt></a></b>
<dd>
The type of open file objects such as <tt>sys.stdout</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-312"><tt>XRangeType</tt></a></b>
<dd>
The type of range objects returned by
<tt class=function>xrange()</tt><a name="l2h-319"></a>.
</dl>

<P>
<dl><dt><b><a name="l2h-313"><tt>SliceType</tt></a></b>
<dd>
The type of objects returned by
<tt class=function>slice()</tt><a name="l2h-320"></a>.
</dl>

<P>
<dl><dt><b><a name="l2h-314"><tt>EllipsisType</tt></a></b>
<dd>
The type of <tt>Ellipsis</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-315"><tt>TracebackType</tt></a></b>
<dd>
The type of traceback objects such as found in
<tt>sys.exc_traceback</tt>.
</dl>

<P>
<dl><dt><b><a name="l2h-316"><tt>FrameType</tt></a></b>
<dd>
The type of frame objects such as found in <tt>tb.tb_frame</tt> if
<tt>tb</tt> is a traceback object.
</dl><p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-UserDict.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="python.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-sys.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-UserDict.html">3.3 UserDict  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="python.html">3. Python Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-sys.html">3.1 sys  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
