<!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>Module: utils.signatures — IPython 2.3.0 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: '2.3.0', 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> <link rel="top" title="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: utils.strdispatch" href="IPython.utils.strdispatch.html" /> <link rel="prev" title="Module: utils.rlineimpl" href="IPython.utils.rlineimpl.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <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="IPython.utils.strdispatch.html" title="Module: utils.strdispatch" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.utils.rlineimpl.html" title="Module: utils.rlineimpl" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">utils.signatures</span></tt></a><ul> <li><a class="reference internal" href="#classes">3 Classes</a></li> <li><a class="reference internal" href="#functions">2 Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.utils.rlineimpl.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">utils.rlineimpl</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.utils.strdispatch.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">utils.strdispatch</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.utils.signatures.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" /> <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="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.utils.signatures"> <span id="module-utils-signatures"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">utils.signatures</span></tt><a class="headerlink" href="#module-IPython.utils.signatures" title="Permalink to this headline">¶</a></h1> <p>Function signature objects for callables.</p> <p>Back port of Python 3.3’s function signature tools from the inspect module, modified to be compatible with Python 2.7 and 3.2+.</p> <div class="section" id="classes"> <h2>3 Classes<a class="headerlink" href="#classes" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.utils.signatures.Parameter"> <em class="property">class </em><tt class="descclassname">IPython.utils.signatures.</tt><tt class="descname">Parameter</tt><big>(</big><em>name</em>, <em>kind</em>, <em>default=<class 'IPython.utils.signatures._empty'></em>, <em>annotation=<class 'IPython.utils.signatures._empty'></em>, <em>_partial_kwarg=False</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Parameter" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference external" href="http://docs.python.org/2/library/functions.html#object" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></a></p> <p>Represents a parameter in a function signature.</p> <p>Has the following public attributes:</p> <ul> <li><dl class="first docutils"> <dt>name <span class="classifier-delimiter">:</span> <span class="classifier">str</span></dt> <dd><p class="first last">The name of the parameter as a string.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>default <span class="classifier-delimiter">:</span> <span class="classifier">object</span></dt> <dd><p class="first last">The default value for the parameter if specified. If the parameter has no default value, this attribute is not set.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>annotation</dt> <dd><p class="first last">The annotation for the parameter if specified. If the parameter has no annotation, this attribute is not set.</p> </dd> </dl> </li> <li><dl class="first docutils"> <dt>kind <span class="classifier-delimiter">:</span> <span class="classifier">str</span></dt> <dd><p class="first last">Describes how argument values are bound to the parameter. Possible values: <cite>Parameter.POSITIONAL_ONLY</cite>, <cite>Parameter.POSITIONAL_OR_KEYWORD</cite>, <cite>Parameter.VAR_POSITIONAL</cite>, <cite>Parameter.KEYWORD_ONLY</cite>, <cite>Parameter.VAR_KEYWORD</cite>.</p> </dd> </dl> </li> </ul> <dl class="method"> <dt id="IPython.utils.signatures.Parameter.__init__"> <tt class="descname">__init__</tt><big>(</big><em>name</em>, <em>kind</em>, <em>default=<class 'IPython.utils.signatures._empty'></em>, <em>annotation=<class 'IPython.utils.signatures._empty'></em>, <em>_partial_kwarg=False</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Parameter.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.utils.signatures.Parameter.replace"> <tt class="descname">replace</tt><big>(</big><em>name=<class 'IPython.utils.signatures._void'></em>, <em>kind=<class 'IPython.utils.signatures._void'></em>, <em>annotation=<class 'IPython.utils.signatures._void'></em>, <em>default=<class 'IPython.utils.signatures._void'></em>, <em>_partial_kwarg=<class 'IPython.utils.signatures._void'></em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Parameter.replace" title="Permalink to this definition">¶</a></dt> <dd><p>Creates a customized copy of the Parameter.</p> </dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.utils.signatures.BoundArguments"> <em class="property">class </em><tt class="descclassname">IPython.utils.signatures.</tt><tt class="descname">BoundArguments</tt><big>(</big><em>signature</em>, <em>arguments</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.BoundArguments" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference external" href="http://docs.python.org/2/library/functions.html#object" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></a></p> <p>Result of <a class="reference internal" href="#IPython.utils.signatures.Signature.bind" title="IPython.utils.signatures.Signature.bind"><tt class="xref py py-meth docutils literal"><span class="pre">Signature.bind()</span></tt></a> call. Holds the mapping of arguments to the function’s parameters.</p> <p>Has the following public attributes:</p> <dl class="docutils"> <dt>arguments <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference external" href="http://docs.python.org/2/library/collections.html#collections.OrderedDict" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">collections.OrderedDict</span></tt></a></span></dt> <dd>An ordered mutable mapping of parameters’ names to arguments’ values. Does not contain arguments’ default values.</dd> <dt>signature <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference internal" href="#IPython.utils.signatures.Signature" title="IPython.utils.signatures.Signature"><tt class="xref py py-class docutils literal"><span class="pre">Signature</span></tt></a></span></dt> <dd>The Signature object that created this instance.</dd> <dt>args <span class="classifier-delimiter">:</span> <span class="classifier">tuple</span></dt> <dd>Tuple of positional arguments values.</dd> <dt>kwargs <span class="classifier-delimiter">:</span> <span class="classifier">dict</span></dt> <dd>Dict of keyword arguments values.</dd> </dl> <dl class="method"> <dt id="IPython.utils.signatures.BoundArguments.__init__"> <tt class="descname">__init__</tt><big>(</big><em>signature</em>, <em>arguments</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.BoundArguments.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> <dl class="class"> <dt id="IPython.utils.signatures.Signature"> <em class="property">class </em><tt class="descclassname">IPython.utils.signatures.</tt><tt class="descname">Signature</tt><big>(</big><em>parameters=None</em>, <em>return_annotation=<class 'IPython.utils.signatures._empty'></em>, <em>__validate_parameters__=True</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference external" href="http://docs.python.org/2/library/functions.html#object" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></a></p> <p>A Signature object represents the overall signature of a function. It stores a Parameter object for each parameter accepted by the function, as well as information specific to the function itself.</p> <p>A Signature object has the following public attributes:</p> <dl class="docutils"> <dt>parameters <span class="classifier-delimiter">:</span> <span class="classifier"><a class="reference external" href="http://docs.python.org/2/library/collections.html#collections.OrderedDict" title="(in Python v2.7)"><tt class="xref py py-class docutils literal"><span class="pre">collections.OrderedDict</span></tt></a></span></dt> <dd>An ordered mapping of parameters’ names to the corresponding Parameter objects (keyword-only arguments are in the same order as listed in <cite>code.co_varnames</cite>).</dd> <dt>return_annotation</dt> <dd>The annotation for the return type of the function if specified. If the function has no annotation for its return type, this attribute is not set.</dd> </dl> <dl class="method"> <dt id="IPython.utils.signatures.Signature.__init__"> <tt class="descname">__init__</tt><big>(</big><em>parameters=None</em>, <em>return_annotation=<class 'IPython.utils.signatures._empty'></em>, <em>__validate_parameters__=True</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Constructs Signature from the given list of Parameter objects and ‘return_annotation’. All arguments are optional.</p> </dd></dl> <dl class="method"> <dt id="IPython.utils.signatures.Signature.bind"> <tt class="descname">bind</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature.bind" title="Permalink to this definition">¶</a></dt> <dd><p>Get a <a class="reference internal" href="#IPython.utils.signatures.BoundArguments" title="IPython.utils.signatures.BoundArguments"><tt class="xref py py-class docutils literal"><span class="pre">BoundArguments</span></tt></a> object, that maps the passed <cite>args</cite> and <cite>kwargs</cite> to the function’s signature. Raises <tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt> if the passed arguments can not be bound.</p> </dd></dl> <dl class="method"> <dt id="IPython.utils.signatures.Signature.bind_partial"> <tt class="descname">bind_partial</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature.bind_partial" title="Permalink to this definition">¶</a></dt> <dd><p>Get a <a class="reference internal" href="#IPython.utils.signatures.BoundArguments" title="IPython.utils.signatures.BoundArguments"><tt class="xref py py-class docutils literal"><span class="pre">BoundArguments</span></tt></a> object, that partially maps the passed <cite>args</cite> and <cite>kwargs</cite> to the function’s signature. Raises <tt class="xref py py-exc docutils literal"><span class="pre">TypeError</span></tt> if the passed arguments can not be bound.</p> </dd></dl> <dl class="classmethod"> <dt id="IPython.utils.signatures.Signature.from_function"> <em class="property">classmethod </em><tt class="descname">from_function</tt><big>(</big><em>func</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature.from_function" title="Permalink to this definition">¶</a></dt> <dd><p>Constructs Signature for the given python function</p> </dd></dl> <dl class="method"> <dt id="IPython.utils.signatures.Signature.replace"> <tt class="descname">replace</tt><big>(</big><em>parameters=<class 'IPython.utils.signatures._void'></em>, <em>return_annotation=<class 'IPython.utils.signatures._void'></em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.Signature.replace" title="Permalink to this definition">¶</a></dt> <dd><p>Creates a customized copy of the Signature. Pass ‘parameters’ and/or ‘return_annotation’ arguments to override them in the new copy.</p> </dd></dl> </dd></dl> </div> <div class="section" id="functions"> <h2>2 Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.utils.signatures.formatannotation"> <tt class="descclassname">IPython.utils.signatures.</tt><tt class="descname">formatannotation</tt><big>(</big><em>annotation</em>, <em>base_module=None</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.formatannotation" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="function"> <dt id="IPython.utils.signatures.signature"> <tt class="descclassname">IPython.utils.signatures.</tt><tt class="descname">signature</tt><big>(</big><em>obj</em><big>)</big><a class="headerlink" href="#IPython.utils.signatures.signature" title="Permalink to this definition">¶</a></dt> <dd><p>Get a signature object for the passed callable.</p> </dd></dl> </div> </div> </div> </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="IPython.utils.strdispatch.html" title="Module: utils.strdispatch" >next</a> |</li> <li class="right" > <a href="IPython.utils.rlineimpl.html" title="Module: utils.rlineimpl" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Jul 14, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>