<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>7.10. types — Names for built-in types — Python v3.2.2 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '3.2.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python v3.2.2 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python v3.2.2 documentation" href="../index.html" /> <link rel="up" title="7. Data Types" href="datatypes.html" /> <link rel="next" title="7.11. copy — Shallow and deep copy operations" href="copy.html" /> <link rel="prev" title="7.9. weakref — Weak references" href="weakref.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="copy.html" title="7.11. copy — Shallow and deep copy operations" accesskey="N">next</a> |</li> <li class="right" > <a href="weakref.html" title="7.9. weakref — Weak references" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="../index.html">Python v3.2.2 documentation</a> »</li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="datatypes.html" accesskey="U">7. Data Types</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-types"> <span id="types-names-for-built-in-types"></span><h1>7.10. <a class="reference internal" href="#module-types" title="types: Names for built-in types."><tt class="xref py py-mod docutils literal"><span class="pre">types</span></tt></a> — Names for built-in types<a class="headerlink" href="#module-types" title="Permalink to this headline">¶</a></h1> <p><strong>Source code:</strong> <a class="reference external" href="http://hg.python.org/cpython/file/3.2/Lib/types.py">Lib/types.py</a></p> <hr class="docutils" /> <p>This module defines names for some object types that are used by the standard Python interpreter, but not exposed as builtins like <a class="reference internal" href="functions.html#int" title="int"><tt class="xref py py-class docutils literal"><span class="pre">int</span></tt></a> or <a class="reference internal" href="functions.html#str" title="str"><tt class="xref py py-class docutils literal"><span class="pre">str</span></tt></a> are. Also, it does not include some of the types that arise transparently during processing such as the <tt class="docutils literal"><span class="pre">listiterator</span></tt> type.</p> <p>Typical use is for <a class="reference internal" href="functions.html#isinstance" title="isinstance"><tt class="xref py py-func docutils literal"><span class="pre">isinstance()</span></tt></a> or <a class="reference internal" href="functions.html#issubclass" title="issubclass"><tt class="xref py py-func docutils literal"><span class="pre">issubclass()</span></tt></a> checks.</p> <p>The module defines the following names:</p> <dl class="data"> <dt id="types.FunctionType"> <tt class="descclassname">types.</tt><tt class="descname">FunctionType</tt><a class="headerlink" href="#types.FunctionType" title="Permalink to this definition">¶</a></dt> <dt id="types.LambdaType"> <tt class="descclassname">types.</tt><tt class="descname">LambdaType</tt><a class="headerlink" href="#types.LambdaType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of user-defined functions and functions created by <a class="reference internal" href="../reference/expressions.html#lambda"><tt class="xref std std-keyword docutils literal"><span class="pre">lambda</span></tt></a> expressions.</p> </dd></dl> <dl class="data"> <dt id="types.GeneratorType"> <tt class="descclassname">types.</tt><tt class="descname">GeneratorType</tt><a class="headerlink" href="#types.GeneratorType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of <a class="reference internal" href="../glossary.html#term-generator"><em class="xref std std-term">generator</em></a>-iterator objects, produced by calling a generator function.</p> </dd></dl> <dl class="data"> <dt id="types.CodeType"> <tt class="descclassname">types.</tt><tt class="descname">CodeType</tt><a class="headerlink" href="#types.CodeType" title="Permalink to this definition">¶</a></dt> <dd><p id="index-0">The type for code objects such as returned by <a class="reference internal" href="functions.html#compile" title="compile"><tt class="xref py py-func docutils literal"><span class="pre">compile()</span></tt></a>.</p> </dd></dl> <dl class="data"> <dt id="types.MethodType"> <tt class="descclassname">types.</tt><tt class="descname">MethodType</tt><a class="headerlink" href="#types.MethodType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of methods of user-defined class instances.</p> </dd></dl> <dl class="data"> <dt id="types.BuiltinFunctionType"> <tt class="descclassname">types.</tt><tt class="descname">BuiltinFunctionType</tt><a class="headerlink" href="#types.BuiltinFunctionType" title="Permalink to this definition">¶</a></dt> <dt id="types.BuiltinMethodType"> <tt class="descclassname">types.</tt><tt class="descname">BuiltinMethodType</tt><a class="headerlink" href="#types.BuiltinMethodType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of built-in functions like <a class="reference internal" href="functions.html#len" title="len"><tt class="xref py py-func docutils literal"><span class="pre">len()</span></tt></a> or <a class="reference internal" href="sys.html#sys.exit" title="sys.exit"><tt class="xref py py-func docutils literal"><span class="pre">sys.exit()</span></tt></a>, and methods of built-in classes. (Here, the term “built-in” means “written in C”.)</p> </dd></dl> <dl class="data"> <dt id="types.ModuleType"> <tt class="descclassname">types.</tt><tt class="descname">ModuleType</tt><a class="headerlink" href="#types.ModuleType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of modules.</p> </dd></dl> <dl class="data"> <dt id="types.TracebackType"> <tt class="descclassname">types.</tt><tt class="descname">TracebackType</tt><a class="headerlink" href="#types.TracebackType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of traceback objects such as found in <tt class="docutils literal"><span class="pre">sys.exc_info()[2]</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="types.FrameType"> <tt class="descclassname">types.</tt><tt class="descname">FrameType</tt><a class="headerlink" href="#types.FrameType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of frame objects such as found in <tt class="docutils literal"><span class="pre">tb.tb_frame</span></tt> if <tt class="docutils literal"><span class="pre">tb</span></tt> is a traceback object.</p> </dd></dl> <dl class="data"> <dt id="types.GetSetDescriptorType"> <tt class="descclassname">types.</tt><tt class="descname">GetSetDescriptorType</tt><a class="headerlink" href="#types.GetSetDescriptorType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of objects defined in extension modules with <tt class="docutils literal"><span class="pre">PyGetSetDef</span></tt>, such as <tt class="docutils literal"><span class="pre">FrameType.f_locals</span></tt> or <tt class="docutils literal"><span class="pre">array.array.typecode</span></tt>. This type is used as descriptor for object attributes; it has the same purpose as the <a class="reference internal" href="functions.html#property" title="property"><tt class="xref py py-class docutils literal"><span class="pre">property</span></tt></a> type, but for classes defined in extension modules.</p> </dd></dl> <dl class="data"> <dt id="types.MemberDescriptorType"> <tt class="descclassname">types.</tt><tt class="descname">MemberDescriptorType</tt><a class="headerlink" href="#types.MemberDescriptorType" title="Permalink to this definition">¶</a></dt> <dd><p>The type of objects defined in extension modules with <tt class="docutils literal"><span class="pre">PyMemberDef</span></tt>, such as <tt class="docutils literal"><span class="pre">datetime.timedelta.days</span></tt>. This type is used as descriptor for simple C data members which use standard conversion functions; it has the same purpose as the <a class="reference internal" href="functions.html#property" title="property"><tt class="xref py py-class docutils literal"><span class="pre">property</span></tt></a> type, but for classes defined in extension modules.</p> <div class="impl-detail compound"> <p><strong>CPython implementation detail:</strong> In other implementations of Python, this type may be identical to <tt class="docutils literal"><span class="pre">GetSetDescriptorType</span></tt>.</p> </div> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="weakref.html" title="previous chapter">7.9. <tt class="docutils literal docutils literal"><span class="pre">weakref</span></tt> — Weak references</a></p> <h4>Next topic</h4> <p class="topless"><a href="copy.html" title="next chapter">7.11. <tt class="docutils literal docutils literal docutils literal"><span class="pre">copy</span></tt> — Shallow and deep copy operations</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/types.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" size="18" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="copy.html" title="7.11. copy — Shallow and deep copy operations" >next</a> |</li> <li class="right" > <a href="weakref.html" title="7.9. weakref — Weak references" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="../index.html">Python v3.2.2 documentation</a> »</li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="datatypes.html" >7. Data Types</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Sep 04, 2011. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7. </div> </body> </html>