Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-updates > by-pkgid > b9a6a1b9f2781444d2917afd8e4421ab > files > 966

ipython-doc-2.3.0-2.2.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>IPython Tips &amp; Tricks &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="Using IPython for interactive work" href="index.html" />
    <link rel="next" title="IPython reference" href="reference.html" />
    <link rel="prev" title="Introducing IPython" href="tutorial.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="reference.html" title="IPython reference"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="Introducing IPython"
             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">Using IPython for interactive work</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="#">IPython Tips &amp; Tricks</a><ul>
<li><a class="reference internal" href="#embed-ipython-in-your-programs">Embed IPython in your programs</a></li>
<li><a class="reference internal" href="#run-doctests">Run doctests</a></li>
<li><a class="reference internal" href="#use-ipython-to-present-interactive-demos">Use IPython to present interactive demos</a></li>
<li><a class="reference internal" href="#suppress-output">Suppress output</a></li>
<li><a class="reference internal" href="#lightweight-version-control">Lightweight &#8216;version control&#8217;</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="tutorial.html"
                        title="previous chapter">Introducing IPython</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="reference.html"
                        title="next chapter">IPython reference</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/interactive/tips.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="ipython-tips-tricks">
<span id="tips"></span><h1>IPython Tips &amp; Tricks<a class="headerlink" href="#ipython-tips-tricks" title="Permalink to this headline">¶</a></h1>
<p>The <a class="reference external" href="https://github.com/ipython/ipython/wiki?path=Cookbook">IPython cookbook</a> details more things
you can do with IPython.</p>
<div class="section" id="embed-ipython-in-your-programs">
<h2>Embed IPython in your programs<a class="headerlink" href="#embed-ipython-in-your-programs" title="Permalink to this headline">¶</a></h2>
<p>A few lines of code are enough to load a complete IPython inside your own
programs, giving you the ability to work with your data interactively after
automatic processing has been completed. See <a class="reference internal" href="reference.html#embedding"><em>the embedding section</em></a>.</p>
</div>
<div class="section" id="run-doctests">
<h2>Run doctests<a class="headerlink" href="#run-doctests" title="Permalink to this headline">¶</a></h2>
<p>Run your doctests from within IPython for development and debugging. The
special %doctest_mode command toggles a mode where the prompt, output and
exceptions display matches as closely as possible that of the default Python
interpreter. In addition, this mode allows you to directly paste in code that
contains leading &#8216;&gt;&gt;&gt;&#8217; prompts, even if they have extra leading whitespace
(as is common in doctest files). This combined with the <tt class="docutils literal"><span class="pre">%history</span> <span class="pre">-t</span></tt> call
to see your translated history allows for an easy doctest workflow, where you
can go from doctest to interactive execution to pasting into valid Python code
as needed.</p>
</div>
<div class="section" id="use-ipython-to-present-interactive-demos">
<h2>Use IPython to present interactive demos<a class="headerlink" href="#use-ipython-to-present-interactive-demos" title="Permalink to this headline">¶</a></h2>
<p>Use the <a class="reference internal" href="../api/generated/IPython.lib.demo.html#IPython.lib.demo.Demo" title="IPython.lib.demo.Demo"><tt class="xref py py-class docutils literal"><span class="pre">IPython.lib.demo.Demo</span></tt></a> class to load any Python script as an interactive
demo. With a minimal amount of simple markup, you can control the execution of
the script, stopping as needed. See <a class="reference internal" href="reference.html#interactive-demos"><em>here</em></a> for more.</p>
</div>
<div class="section" id="suppress-output">
<h2>Suppress output<a class="headerlink" href="#suppress-output" title="Permalink to this headline">¶</a></h2>
<p>Put a &#8216;;&#8217; at the end of a line to suppress the printing of output. This is
useful when doing calculations which generate long output you are not
interested in seeing. It also keeps the object out of the output cache, so if
you&#8217;re working with large temporary objects, they&#8217;ll be released from memory sooner.</p>
</div>
<div class="section" id="lightweight-version-control">
<h2>Lightweight &#8216;version control&#8217;<a class="headerlink" href="#lightweight-version-control" title="Permalink to this headline">¶</a></h2>
<p>When you call <tt class="docutils literal"><span class="pre">%edit</span></tt> with no arguments, IPython opens an empty editor
with a temporary file, and it returns the contents of your editing
session as a string variable. Thanks to IPython&#8217;s output caching
mechanism, this is automatically stored:</p>
<div class="highlight-python"><div class="highlight"><pre>In [1]: %edit

IPython will make a temporary file named: /tmp/ipython_edit_yR-HCN.py

Editing... done. Executing edited code...

hello - this is a temporary file

Out[1]: &quot;print(&#39;hello - this is a temporary file&#39;)\n&quot;
</pre></div>
</div>
<p>Now, if you call <tt class="docutils literal"><span class="pre">%edit</span> <span class="pre">-p</span></tt>, IPython tries to open an editor with the
same data as the last time you used %edit. So if you haven&#8217;t used %edit
in the meantime, this same contents will reopen; however, it will be
done in a new file. This means that if you make changes and you later
want to find an old version, you can always retrieve it by using its
output number, via &#8216;%edit _NN&#8217;, where NN is the number of the output
prompt.</p>
<p>Continuing with the example above, this should illustrate this idea:</p>
<div class="highlight-python"><div class="highlight"><pre>In [2]: edit -p

IPython will make a temporary file named: /tmp/ipython_edit_nA09Qk.py

Editing... done. Executing edited code...

hello - now I made some changes

Out[2]: &quot;print(&#39;hello - now I made some changes&#39;)\n&quot;

In [3]: edit _1

IPython will make a temporary file named: /tmp/ipython_edit_gy6-zD.py

Editing... done. Executing edited code...

hello - this is a temporary file

IPython version control at work :)

Out[3]: &quot;print(&#39;hello - this is a temporary file&#39;)\nprint(&#39;IPython version control at work :)&#39;)\n&quot;
</pre></div>
</div>
<p>This section was written after a contribution by Alexander Belchenko on
the IPython user list.</p>
</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="reference.html" title="IPython reference"
             >next</a> |</li>
        <li class="right" >
          <a href="tutorial.html" title="Introducing IPython"
             >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" >Using IPython for interactive work</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; 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>