Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates > by-pkgid > c044f82ec6193fba7e13c97913613b07 > files > 653

ipython-doc-2.3.0-2.3.mga5.noarch.rpm

<!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: core.magics.namespace &mdash; 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: core.magics.osm" href="IPython.core.magics.osm.html" />
    <link rel="prev" title="Module: core.magics.logging" href="IPython.core.magics.logging.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.core.magics.osm.html" title="Module: core.magics.osm"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="IPython.core.magics.logging.html" title="Module: core.magics.logging"
             accesskey="P">previous</a> |</li>
        <li><a href="http://ipython.org">home</a>|&nbsp;</li>
        <li><a href="../../search.html">search</a>|&nbsp;</li>
       <li><a href="../../index.html">documentation </a> &raquo;</li>

          <li><a href="../index.html" accesskey="U">The IPython API</a> &raquo;</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">core.magics.namespace</span></tt></a><ul>
<li><a class="reference internal" href="#class">1 Class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="IPython.core.magics.logging.html"
                        title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.logging</span></tt></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="IPython.core.magics.osm.html"
                        title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.osm</span></tt></a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../../_sources/api/generated/IPython.core.magics.namespace.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.core.magics.namespace">
<span id="module-core-magics-namespace"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.magics.namespace</span></tt><a class="headerlink" href="#module-IPython.core.magics.namespace" title="Permalink to this headline">¶</a></h1>
<p>Implementation of namespace-related magic functions.</p>
<div class="section" id="class">
<h2>1 Class<a class="headerlink" href="#class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="IPython.core.magics.namespace.NamespaceMagics">
<em class="property">class </em><tt class="descclassname">IPython.core.magics.namespace.</tt><tt class="descname">NamespaceMagics</tt><big>(</big><em>shell=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="IPython.core.magic.html#IPython.core.magic.Magics" title="IPython.core.magic.Magics"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.magic.Magics</span></tt></a></p>
<p>Magics to manage various aspects of the user&#8217;s namespace.</p>
<p>These include listing variables, introspecting into them, etc.</p>
<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.pdef">
<tt class="descname">pdef</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.pdef" title="Permalink to this definition">¶</a></dt>
<dd><p>Print the call signature for any callable object.</p>
<p>If the object is a class, print the constructor information.</p>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre>In [3]: %pdef urllib.urlopen
urllib.urlopen(url, data=None, proxies=None)
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.pdoc">
<tt class="descname">pdoc</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.pdoc" title="Permalink to this definition">¶</a></dt>
<dd><p>Print the docstring for an object.</p>
<p>If the given object is a class, it will print both the class and the
constructor docstrings.</p>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.pfile">
<tt class="descname">pfile</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.pfile" title="Permalink to this definition">¶</a></dt>
<dd><p>Print (or run through pager) the file where an object is defined.</p>
<p>The file opens at the line where the object definition begins. IPython
will honor the environment variable PAGER if set, and otherwise will
do its best to print the file in a convenient form.</p>
<p>If the given argument is not an object currently defined, IPython will
try to interpret it as a filename (automatically adding a .py extension
if needed). You can thus use %pfile as a syntax highlighting code
viewer.</p>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.pinfo">
<tt class="descname">pinfo</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.pinfo" title="Permalink to this definition">¶</a></dt>
<dd><p>Provide detailed information about an object.</p>
<p>&#8216;%pinfo object&#8217; is just a synonym for object? or ?object.</p>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.pinfo2">
<tt class="descname">pinfo2</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.pinfo2" title="Permalink to this definition">¶</a></dt>
<dd><p>Provide extra detailed information about an object.</p>
<p>&#8216;%pinfo2 object&#8217; is just a synonym for object?? or ??object.</p>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.psearch">
<tt class="descname">psearch</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.psearch" title="Permalink to this definition">¶</a></dt>
<dd><p>Search for object in namespaces by wildcard.</p>
<p>%psearch [options] PATTERN [OBJECT TYPE]</p>
<p>Note: ? can be used as a synonym for %psearch, at the beginning or at
the end: both a*? and ?a* are equivalent to &#8216;%psearch a*&#8217;.  Still, the
rest of the command line must be unchanged (options come first), so
for example the following forms are equivalent</p>
<p>%psearch -i a* function
-i a* function?
?-i a* function</p>
<p>Arguments:</p>
<blockquote>
<div><p>PATTERN</p>
<p>where PATTERN is a string containing * as a wildcard similar to its
use in a shell.  The pattern is matched in all namespaces on the
search path. By default objects starting with a single _ are not
matched, many IPython generated objects have a single
underscore. The default is case insensitive matching. Matching is
also done on the attributes of objects and not only on the objects
in a module.</p>
<p>[OBJECT TYPE]</p>
<p>Is the name of a python type from the types module. The name is
given in lowercase without the ending type, ex. StringType is
written string. By adding a type here only objects matching the
given type are matched. Using all here makes the pattern match all
types (this is the default).</p>
</div></blockquote>
<p>Options:</p>
<blockquote>
<div><p>-a: makes the pattern match even objects whose names start with a
single underscore.  These names are normally omitted from the
search.</p>
<p>-i/-c: make the pattern case insensitive/sensitive.  If neither of
these options are given, the default is read from your configuration
file, with the option <tt class="docutils literal"><span class="pre">InteractiveShell.wildcards_case_sensitive</span></tt>.
If this option is not specified in your configuration file, IPython&#8217;s
internal default is to do a case sensitive search.</p>
<p>-e/-s NAMESPACE: exclude/search a given namespace.  The pattern you
specify can be searched in any of the following namespaces:
&#8216;builtin&#8217;, &#8216;user&#8217;, &#8216;user_global&#8217;,&#8217;internal&#8217;, &#8216;alias&#8217;, where
&#8216;builtin&#8217; and &#8216;user&#8217; are the search defaults.  Note that you should
not use quotes when specifying namespaces.</p>
<p>&#8216;Builtin&#8217; contains the python module builtin, &#8216;user&#8217; contains all
user data, &#8216;alias&#8217; only contain the shell aliases and no python
objects, &#8216;internal&#8217; contains objects used by IPython.  The
&#8216;user_global&#8217; namespace is only used by embedded IPython instances,
and it contains module-level globals.  You can add namespaces to the
search with -s or exclude them with -e (these options can be given
more than once).</p>
</div></blockquote>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre>%psearch a*            -&gt; objects beginning with an a
%psearch -e builtin a* -&gt; objects NOT in the builtin space starting in a
%psearch a* function   -&gt; all functions beginning with an a
%psearch re.e*         -&gt; objects beginning with an e in module re
%psearch r*.e*         -&gt; objects that start with e in modules starting in r
%psearch r*.* string   -&gt; all strings in modules beginning with r
</pre></div>
</div>
<p>Case sensitive search:</p>
<div class="highlight-python"><div class="highlight"><pre>%psearch -c a*         list all object beginning with lower case a
</pre></div>
</div>
<p>Show objects beginning with a single _:</p>
<div class="highlight-python"><div class="highlight"><pre>%psearch -a _*         list objects beginning with a single underscore
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.psource">
<tt class="descname">psource</tt><big>(</big><em>parameter_s=''</em>, <em>namespaces=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.psource" title="Permalink to this definition">¶</a></dt>
<dd><p>Print (or run through pager) the source code for an object.</p>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.reset">
<tt class="descname">reset</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the namespace by removing all names defined by the user, if
called without arguments, or by removing some types of objects, such
as everything currently in IPython&#8217;s In[] and Out[] containers (see
the parameters for details).</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"><p class="first"><strong>-f</strong> : force reset without asking for confirmation.</p>
<p><strong>-s</strong> : &#8216;Soft&#8217; reset: Only clears your namespace, leaving history intact.</p>
<blockquote>
<div><p>References to objects may be kept. By default (without this option),
we do a &#8216;hard&#8217; reset, giving you a new session and removing all
references to objects from the current session.</p>
</div></blockquote>
<p><strong>in</strong> : reset input history</p>
<p><strong>out</strong> : reset output history</p>
<p><strong>dhist</strong> : reset directory history</p>
<p class="last"><strong>array</strong> : reset only variables that are NumPy arrays</p>
</td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#IPython.core.magics.namespace.NamespaceMagics.reset_selective" title="IPython.core.magics.namespace.NamespaceMagics.reset_selective"><tt class="xref py py-obj docutils literal"><span class="pre">reset_selective</span></tt></a></dt>
<dd>invoked as <tt class="docutils literal"><span class="pre">%reset_selective</span></tt></dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>Calling this magic from clients that do not implement standard input,
such as the ipython notebook interface, will reset the namespace
without confirmation.</p>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre>In [6]: a = 1

In [7]: a
Out[7]: 1

In [8]: &#39;a&#39; in _ip.user_ns
Out[8]: True

In [9]: %reset -f

In [1]: &#39;a&#39; in _ip.user_ns
Out[1]: False

In [2]: %reset -f in
Flushing input history

In [3]: %reset -f dhist in
Flushing directory history
Flushing input history
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.reset_selective">
<tt class="descname">reset_selective</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.reset_selective" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the namespace by removing names defined by the user.</p>
<p>Input/Output history are left around in case you need them.</p>
<p>%reset_selective [-f] regex</p>
<p>No action is taken if regex is not included</p>
<dl class="docutils">
<dt>Options</dt>
<dd>-f : force reset without asking for confirmation.</dd>
</dl>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="#IPython.core.magics.namespace.NamespaceMagics.reset" title="IPython.core.magics.namespace.NamespaceMagics.reset"><tt class="xref py py-obj docutils literal"><span class="pre">reset</span></tt></a></dt>
<dd>invoked as <tt class="docutils literal"><span class="pre">%reset</span></tt></dd>
</dl>
</div>
<p class="rubric">Notes</p>
<p>Calling this magic from clients that do not implement standard input,
such as the ipython notebook interface, will reset the namespace
without confirmation.</p>
<p class="rubric">Examples</p>
<p>We first fully reset the namespace so your output looks identical to
this example for pedagogical reasons; in practice you do not need a
full reset:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: %reset -f
</pre></div>
</div>
<p>Now, with a clean namespace we can make a few variables and use
<tt class="docutils literal"><span class="pre">%reset_selective</span></tt> to only delete names that match our regexp:</p>
<div class="highlight-python"><div class="highlight"><pre>In [2]: a=1; b=2; c=3; b1m=4; b2m=5; b3m=6; b4m=7; b2s=8

In [3]: who_ls
Out[3]: [&#39;a&#39;, &#39;b&#39;, &#39;b1m&#39;, &#39;b2m&#39;, &#39;b2s&#39;, &#39;b3m&#39;, &#39;b4m&#39;, &#39;c&#39;]

In [4]: %reset_selective -f b[2-3]m

In [5]: who_ls
Out[5]: [&#39;a&#39;, &#39;b&#39;, &#39;b1m&#39;, &#39;b2s&#39;, &#39;b4m&#39;, &#39;c&#39;]

In [6]: %reset_selective -f d

In [7]: who_ls
Out[7]: [&#39;a&#39;, &#39;b&#39;, &#39;b1m&#39;, &#39;b2s&#39;, &#39;b4m&#39;, &#39;c&#39;]

In [8]: %reset_selective -f c

In [9]: who_ls
Out[9]: [&#39;a&#39;, &#39;b&#39;, &#39;b1m&#39;, &#39;b2s&#39;, &#39;b4m&#39;]

In [10]: %reset_selective -f b

In [11]: who_ls
Out[11]: [&#39;a&#39;]
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.who">
<tt class="descname">who</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.who" title="Permalink to this definition">¶</a></dt>
<dd><p>Print all interactive variables, with some minimal formatting.</p>
<p>If any arguments are given, only variables whose type matches one of
these are printed.  For example:</p>
<div class="highlight-python"><div class="highlight"><pre>%who function str
</pre></div>
</div>
<p>will only list functions and strings, excluding all other types of
variables.  To find the proper type names, simply use type(var) at a
command line to see how python prints type names.  For example:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: type(&#39;hello&#39;)\
Out[1]: &lt;type &#39;str&#39;&gt;
</pre></div>
</div>
<p>indicates that the type name for strings is &#8216;str&#8217;.</p>
<p><tt class="docutils literal"><span class="pre">%who</span></tt> always excludes executed names loaded through your configuration
file and things which are internal to IPython.</p>
<p>This is deliberate, as typically you may load many modules and the
purpose of %who is to show you only what you&#8217;ve manually defined.</p>
<p class="rubric">Examples</p>
<p>Define two variables and list them with who:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: alpha = 123

In [2]: beta = &#39;test&#39;

In [3]: %who
alpha   beta

In [4]: %who int
alpha

In [5]: %who str
beta
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.who_ls">
<tt class="descname">who_ls</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.who_ls" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a sorted list of all interactive variables.</p>
<p>If arguments are given, only variables of types matching these
arguments are returned.</p>
<p class="rubric">Examples</p>
<p>Define two variables and list them with who_ls:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: alpha = 123

In [2]: beta = &#39;test&#39;

In [3]: %who_ls
Out[3]: [&#39;alpha&#39;, &#39;beta&#39;]

In [4]: %who_ls int
Out[4]: [&#39;alpha&#39;]

In [5]: %who_ls str
Out[5]: [&#39;beta&#39;]
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.whos">
<tt class="descname">whos</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.whos" title="Permalink to this definition">¶</a></dt>
<dd><p>Like %who, but gives some extra information about each variable.</p>
<p>The same type filtering of %who can be applied here.</p>
<p>For all variables, the type is printed. Additionally it prints:</p>
<blockquote>
<div><ul class="simple">
<li>For {},[],(): their length.</li>
<li>For numpy arrays, a summary with shape, number of
elements, typecode and size in memory.</li>
<li>Everything else: a string representation, snipping their middle if
too long.</li>
</ul>
</div></blockquote>
<p class="rubric">Examples</p>
<p>Define two variables and list them with whos:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: alpha = 123

In [2]: beta = &#39;test&#39;

In [3]: %whos
Variable   Type        Data/Info
--------------------------------
alpha      int         123
beta       str         test
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="IPython.core.magics.namespace.NamespaceMagics.xdel">
<tt class="descname">xdel</tt><big>(</big><em>parameter_s=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.namespace.NamespaceMagics.xdel" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete a variable, trying to clear it from anywhere that
IPython&#8217;s machinery has references to it. By default, this uses
the identity of the named object in the user namespace to remove
references held under other names. The object is also removed
from the output history.</p>
<dl class="docutils">
<dt>Options</dt>
<dd>-n : Delete the specified name from all namespaces, without
checking their identity.</dd>
</dl>
</dd></dl>

</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.core.magics.osm.html" title="Module: core.magics.osm"
             >next</a> |</li>
        <li class="right" >
          <a href="IPython.core.magics.logging.html" title="Module: core.magics.logging"
             >previous</a> |</li>
        <li><a href="http://ipython.org">home</a>|&nbsp;</li>
        <li><a href="../../search.html">search</a>|&nbsp;</li>
       <li><a href="../../index.html">documentation </a> &raquo;</li>

          <li><a href="../index.html" >The IPython API</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright The IPython Development Team.
      Last updated on Sep 02, 2015.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
    </div>
  </body>
</html>