<!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 Directive &mdash; ipymode v0.1 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.1',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="ipymode v0.1 documentation" href="index.html" />
    <link rel="prev" title="Welcome to ipymode’s documentation!" href="index.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="index.html" title="Welcome to ipymode’s documentation!"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">ipymode v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="ipython-directive">
<h1>Ipython Directive<a class="headerlink" href="#ipython-directive" title="Permalink to this headline">¶</a></h1>
<p>The ipython directive is a stateful ipython shell for embedding in
sphinx documents.</p>
<div class="highlight-ipython"><div class="highlight"><pre><span class="gp">In [1]: </span><span class="n">x</span> <span class="o">=</span> <span class="mf">2</span>

<span class="gp">In [2]: </span><span class="n">x</span><span class="o">**</span><span class="mf">3</span>
<span class="gr">Out[2]: </span><span class="mf">8</span>
</pre></div>
</div>
<p>The state from previous sessions is stored, and standard error is
trapped</p>
<div class="highlight-ipython"><div class="highlight"><pre><span class="gp">In [3]: </span><span class="n">z</span> <span class="o">=</span> <span class="n">x</span><span class="o">*</span><span class="mf">3</span>   <span class="c"># x is recalled from previous block</span>

<span class="gp">In [4]: </span><span class="n">z</span>
<span class="gr">Out[4]: </span><span class="mf">6</span>

<span class="gp">In [5]: </span><span class="k">print</span> <span class="n">z</span>   <span class="c"># this doesn&#39;t produce output -- how do I capture this?</span>

<span class="gp">In [6]: </span><span class="n">q</span> <span class="o">=</span> <span class="n">z</span><span class="p">[)</span>   <span class="c"># this is a syntax error -- we trap ipy exceptions</span>
<span class="go">------------------------------------------------------------</span>
<span class="go">   File &quot;&lt;ipython console&gt;&quot;, line 1</span>
<span class="go">     q = z[)   # this is a syntax error -- we trap ipy exceptions</span>
<span class="go">           ^</span>
<span class="go">SyntaxError: invalid syntax</span>
</pre></div>
</div>
<p>That&#8217;s it &#8211; next step is supporting pylab with embedded figs!</p>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="index.html"
                                  title="previous chapter">Welcome to ipymode&#8217;s documentation!</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/testipy.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="index.html" title="Welcome to ipymode’s documentation!"
             >previous</a> |</li>
        <li><a href="index.html">ipymode v0.1 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009, jdh.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.
    </div>
  </body>
</html>