snipt

Ctrl+h for KB shortcuts

Python

Continue only when running interactively in IPython

1
2
3
# Continue only when running interactively in IPython
try:              __IPYTHON__
except NameError: raise SystemExit, 0
https://snipt.net/embed/3f3ec65c21a8d51d10028a435c72e984/
https://snipt.net/raw/3f3ec65c21a8d51d10028a435c72e984/
3f3ec65c21a8d51d10028a435c72e984
python
Python
4
2016-09-26T07:26:27
True
False
False
Jan 09, 2013 at 11:34 AM
/api/public/snipt/53034/
continue-only-when-running-interactively-in-ipython
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># Continue only when running interactively in IPython</span> </span><span id="L-2"><a name="L-2"></a><span class="k">try</span><span class="p">:</span> <span class="n">__IPYTHON__</span> </span><span id="L-3"><a name="L-3"></a><span class="k">except</span> <span class="ne">NameError</span><span class="p">:</span> <span class="k">raise</span> <span class="ne">SystemExit</span><span class="p">,</span> <span class="mi">0</span> </span></pre></div> </td></tr></table>
ipython, main

Bash

list programming history

1
2
3
4
5
# to list all history
hist

# to list a range of commands
print In[0:30]
https://snipt.net/embed/0633256ba29765ee35928296c259822f/
https://snipt.net/raw/0633256ba29765ee35928296c259822f/
0633256ba29765ee35928296c259822f
bash
Bash
5
2016-09-20T19:17:34
True
False
False
/api/public/snipt/2714/
list-programming-history
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c"># to list all history</span> </span><span id="L-2"><a name="L-2"></a>hist </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c"># to list a range of commands</span> </span><span id="L-5"><a name="L-5"></a>print In<span class="o">[</span>0:30<span class="o">]</span> </span></pre></div> </td></tr></table>
ipython
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.