<!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>tools.utils — IPython 0.10.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: '0.10.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> <link rel="top" title="IPython 0.10.2 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="twshell" href="IPython.twshell.html" /> <link rel="prev" title="tools.growl" href="IPython.tools.growl.html" /> </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="IPython.twshell.html" title="twshell" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.tools.growl.html" title="tools.growl" accesskey="P">previous</a> |</li> <li><a href="../../index.html">IPython 0.10.2 documentation</a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="tools-utils"> <h1>tools.utils<a class="headerlink" href="#tools-utils" title="Permalink to this headline">¶</a></h1> <div class="section" id="module-IPython.tools.utils"> <span id="module-tools-utils"></span><h2>Module: <tt class="xref py py-mod docutils literal"><span class="pre">tools.utils</span></tt><a class="headerlink" href="#module-IPython.tools.utils" title="Permalink to this headline">¶</a></h2> <p>Generic utilities for use by IPython’s various subsystems.</p> </div> <div class="section" id="functions"> <h2>Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.tools.utils.extractVars"> <tt class="descclassname">IPython.tools.utils.</tt><tt class="descname">extractVars</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.tools.utils.extractVars" title="Permalink to this definition">¶</a></dt> <dd><p>Extract a set of variables by name from another frame.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple"> <li><cite>*names</cite>: strings One or more variable names which will be extracted from the caller’s</li> </ul> </td> </tr> </tbody> </table> <p>frame.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Keywords :</th><td class="field-body"><ul class="first last simple"> <li><cite>depth</cite>: integer (0) How many frames in the stack to walk when looking for your variables.</li> </ul> </td> </tr> </tbody> </table> <p>Examples:</p> <blockquote> <div><dl class="docutils"> <dt>In [2]: def func(x):</dt> <dd>...: y = 1 ...: print extractVars(‘x’,’y’) ...:</dd> </dl> <p>In [3]: func(‘hello’) {‘y’: 1, ‘x’: ‘hello’}</p> </div></blockquote> </dd></dl> <dl class="function"> <dt id="IPython.tools.utils.extractVarsAbove"> <tt class="descclassname">IPython.tools.utils.</tt><tt class="descname">extractVarsAbove</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.tools.utils.extractVarsAbove" title="Permalink to this definition">¶</a></dt> <dd><p>Extract a set of variables by name from another frame.</p> <p>Similar to extractVars(), but with a specified depth of 1, so that names are exctracted exactly from above the caller.</p> <p>This is simply a convenience function so that the very common case (for us) of skipping exactly 1 frame doesn’t have to construct a special dict for keyword passing.</p> </dd></dl> <dl class="function"> <dt id="IPython.tools.utils.list_strings"> <tt class="descclassname">IPython.tools.utils.</tt><tt class="descname">list_strings</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.tools.utils.list_strings" title="Permalink to this definition">¶</a></dt> <dd><p>Always return a list of strings, given a string or list of strings as input.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Examples :</th><td class="field-body"><p class="first">In [7]: list_strings(‘A single string’) Out[7]: [‘A single string’]</p> <p>In [8]: list_strings([‘A single string in a list’]) Out[8]: [‘A single string in a list’]</p> <p class="last">In [9]: list_strings([‘A’,’list’,’of’,’strings’]) Out[9]: [‘A’, ‘list’, ‘of’, ‘strings’]</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="IPython.tools.utils.marquee"> <tt class="descclassname">IPython.tools.utils.</tt><tt class="descname">marquee</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.tools.utils.marquee" title="Permalink to this definition">¶</a></dt> <dd><p>Return the input string centered in a ‘marquee’.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Examples :</th><td class="field-body"><p class="first">In [16]: marquee(‘A test’,40) Out[16]: ‘<strong>************</strong> A test <strong>************</strong>‘</p> <p>In [17]: marquee(‘A test’,40,’-‘) Out[17]: ‘—————- A test —————-‘</p> <p class="last">In [18]: marquee(‘A test’,40,’ ‘) Out[18]: ‘ A test ‘</p> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="IPython.tools.utils.shexp"> <tt class="descclassname">IPython.tools.utils.</tt><tt class="descname">shexp</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.tools.utils.shexp" title="Permalink to this definition">¶</a></dt> <dd><p>Expand $VARS and ~names in a string, like a shell</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Examples :</th><td class="field-body"><p class="first">In [2]: os.environ[‘FOO’]=’test’</p> <p class="last">In [3]: shexp(‘variable FOO is $FOO’) Out[3]: ‘variable FOO is test’</p> </td> </tr> </tbody> </table> </dd></dl> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">tools.utils</a><ul> <li><a class="reference internal" href="#module-IPython.tools.utils">Module: <tt class="docutils literal"><span class="pre">tools.utils</span></tt></a></li> <li><a class="reference internal" href="#functions">Functions</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.tools.growl.html" title="previous chapter">tools.growl</a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.twshell.html" title="next chapter">twshell</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.tools.utils.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="IPython.twshell.html" title="twshell" >next</a> |</li> <li class="right" > <a href="IPython.tools.growl.html" title="tools.growl" >previous</a> |</li> <li><a href="../../index.html">IPython 0.10.2 documentation</a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright 2008, The IPython Development Team. Last updated on Apr 09, 2011. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1pre. </div> </body> </html>