##// END OF EJS Templates
Merge pull request #2728 from Carreau/shifttab...
Merge pull request #2728 from Carreau/shifttab also bind shift tab for tooltip + config This does not change the curent behavior, only add the shift+tab shortcut. Note that the shift tab shortcut has a slightly different behavior. You can select part of a line and pressing shift-tab will show you the tooltip only for the selection. This is disabled for multiline selection to still allow to unindent block of code, Keep in mind that the real real shortcut for indent unindent is Ctrl+] or [ . Select/tab is not really supported by codemirror. Finally the "tooltip_on_tab" behavior is globally configurable via IPython.config so that it could be easily switched to false. It can be overridden via js console for test purpose. IPython.config.tooltip_on_tab = true | false Take effect immediately, only on current notebook. or globally via custom.js var user_conf = {tooltip_on_tab:false | true}; $.extend(IPython.config, user_conf)

File last commit:

r7739:dff285da
r8971:99339d10 merge
Show More
Capturing Output.ipynb
208 lines | 4.2 KiB | text/plain | TextLexer
/ docs / examples / notebooks / Capturing Output.ipynb
MinRK
add demo notebook for %%capture
r7326 {
"metadata": {
"name": "Capturing Output"
},
"nbformat": 3,
MinRK
rebuild example notebooks...
r7739 "nbformat_minor": 0,
MinRK
add demo notebook for %%capture
r7326 "worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "source": [
"Capturing Output with <tt>%%capture</tt>"
]
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "source": [
MinRK
rebuild example notebooks...
r7739 "One of IPython's new cell magics is `%%capture`, which captures stdout/err for a cell,\n",
MinRK
add demo notebook for %%capture
r7326 "and discards them or stores them in variables in your namespace."
]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
"import sys"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "source": [
"By default, it just swallows it up. This is a simple way to suppress unwanted output."
]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
rebuild example notebooks...
r7739 "%%capture\n",
"print 'hi, stdout'\n",
MinRK
add demo notebook for %%capture
r7326 "print >> sys.stderr, 'hi, stderr'"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "source": [
MinRK
update capture per review...
r7408 "If you specify a name, then stdout and stderr will be stored in an object in your namespace."
MinRK
add demo notebook for %%capture
r7326 ]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
rebuild example notebooks...
r7739 "%%capture captured\n",
"print 'hi, stdout'\n",
MinRK
add demo notebook for %%capture
r7326 "print >> sys.stderr, 'hi, stderr'"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
update capture per review...
r7408 "captured"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "outputs": []
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "source": [
"Calling the object writes the output to stdout/err as appropriate."
]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
update capture per review...
r7408 "input": [
"captured()"
MinRK
add demo notebook for %%capture
r7326 ],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
update capture per review...
r7408 "captured.stdout"
MinRK
add demo notebook for %%capture
r7326 ],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
update capture per review...
r7408 "captured.stderr"
MinRK
add demo notebook for %%capture
r7326 ],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "source": [
"`%%capture` only captures stdout/err, not displaypub, so you can still do plots and use the display protocol inside %%capture"
]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
"%pylab inline"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
rebuild example notebooks...
r7739 "%%capture wontshutup\n",
"\n",
"print \"setting up X\"\n",
"x = np.linspace(0,5,1000)\n",
"print \"step 2: constructing y-data\"\n",
"y = np.sin(x)\n",
"print \"step 3: display info about y\"\n",
"plt.plot(x,y)\n",
MinRK
add demo notebook for %%capture
r7326 "print \"okay, I'm done now\""
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
add demo notebook for %%capture
r7326 "input": [
MinRK
update capture per review...
r7408 "wontshutup()"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "outputs": []
},
{
"cell_type": "markdown",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "source": [
"And you can selectively disable capturing stdout or stderr by passing `--no-stdout/err`."
]
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
update capture per review...
r7408 "input": [
MinRK
rebuild example notebooks...
r7739 "%%capture cap --no-stderr\n",
"print 'hi, stdout'\n",
MinRK
update capture per review...
r7408 "print >> sys.stderr, \"hello, stderr\""
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
update capture per review...
r7408 "input": [
"cap.stdout"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
update capture per review...
r7408 "outputs": []
},
{
"cell_type": "code",
MinRK
rebuild example notebooks...
r7739 "collapsed": false,
MinRK
update capture per review...
r7408 "input": [
"cap.stderr"
],
"language": "python",
MinRK
rebuild example notebooks...
r7739 "metadata": {},
MinRK
add demo notebook for %%capture
r7326 "outputs": []
}
MinRK
rebuild example notebooks...
r7739 ],
"metadata": {}
MinRK
add demo notebook for %%capture
r7326 }
]
}