Skip to content

Instantly share code, notes, and snippets.

@damontallen
Last active December 17, 2015 19:09
Show Gist options
  • Save damontallen/5658430 to your computer and use it in GitHub Desktop.
Save damontallen/5658430 to your computer and use it in GitHub Desktop.
This is an IPython Notebook that is used to convert the text generated by quickref into an HTML table.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "Keyed_quick_ref"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Making an quickref HTML table"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Developed by Damon Allen\n",
" * Inspired by this [PDF](http://dl.dropboxusercontent.com/u/54552252/ipython-quickref.pdf)\n",
"* Last Modified: May 27, 2013, 2:20 pm"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This notebook shows the conversion of:\n",
"\n",
"* quickref's text to a dictionary \n",
"* a quickref ditionary to an HTML table"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from pprint import pprint as pr\n",
"from collections import OrderedDict as Or_dict"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def heading_check(lines, index):\n",
" \"\"\"This function determines if the line at the provided is a heading.\"\"\"\n",
" check = (not(lines[index-1]) and not(lines[index+1]))\n",
" #if check:\n",
" # pr(('Heading',lines[index]))\n",
" return check\n",
"\n",
"def title_check(lines, index):\n",
" \"\"\"This functions checks to see if the index is pointing at the title line.\"\"\"\n",
" check = (not(lines[index-1]) and (\"=======\" in lines[index+1]))\n",
" #if check:\n",
" # pr(('Title',lines[index]))\n",
" return check\n",
"\n",
"def right_column_check(lines, index):\n",
" \"\"\"This function determines if the line is part of an explanation, \n",
" e.i. it belongs in the right-hand column\"\"\"\n",
" line = lines[index]\n",
" return (('\\t' in line) or (' ' == line[0:7]))# or ((\":\" in lines[index-1]) and (\":\" not in lines[index])))\n",
"\n",
"def comment_check(lines, index):\n",
" \"\"\"This fuinction determines if the line is a comment rather than an example or a subject header\"\"\"\n",
" check1 = ((\":\" in lines[index-1]) and (\":\" not in lines[index]))\n",
" check2 = (lines[index] and (\":\" not in lines[index-1]) and (\":\" not in lines[index]))\n",
" parts = lines[index].split(':')\n",
" check3 = (not(lines[index-1]) and len(parts)>1 and (parts[0].strip()==parts[0]))\n",
" check4 = not(right_column_check(lines, index))\n",
" check5 = not(right_column_check(lines,index+1))\n",
" check6 = \"=====\" not in lines[index]\n",
" line = lines[index]\n",
" return ((check1 or check2 or check3)and check4 and check5 and check6)\n",
"\n",
"def check_part_key(lines, index):\n",
" \"\"\"This function determines if the current line is actually part of the key for the next line\"\"\"\n",
" check = (\":\" in lines[index-1])and(\":\" in lines[index+1])and(\":\" not in lines[index] and not(right_column_check(lines, index)))\n",
" return check\n",
"\n",
"def check_for_range(lines, index):\n",
" parts = lines[index].split(':')\n",
" return (len(parts)>2 and (\"::\" not in lines[index]))"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 14
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"#Manual Testing\n",
"#Lines = ['',' ?obj, ??obj):.','']\n",
"#Lines = [\":\",' or python names.']\n",
"#Lines = [\":\",'or python names.']\n",
"#Lines = ['',\"alis:\",'\tor python names.']\n",
"#Lines = [\":\",'or python names.::']\n",
"#Lines = [\"\",'or: python names.']\n",
"#Lines = [\"\",'or python names.']\n",
"Lines = [\"\", \"[2:5]:range\"]\n",
"#len(line[0:6])\n",
"#' ' == line[0:7]\n",
"#right_column_check(Lines,1)\n",
"check_for_range(Lines, 1)\n",
"#line.split(':')\n",
"#heading_check(Lines,1)\n",
"#comment_check(Lines,1)\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "pyout",
"prompt_number": 15,
"text": [
"True"
]
}
],
"prompt_number": 15
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"with open(\"quick_ref.txt\",'r') as f:\n",
" quickref_text = f.read()\n",
"lines = quickref_text.split('\\n')\n",
"print(len(lines))"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"251\n"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def build_dict(lines):\n",
" \"\"\"This function takes an array of strings generated by quickref and turns it into an ordered dict\"\"\"\n",
" Quick_ref_dic = Or_dict()\n",
" index = 1\n",
" key_part = ''\n",
" while index<len(lines):\n",
" \"\"\"do something\"\"\"\n",
" #pr(index)\n",
" if title_check(lines, index) or heading_check(lines, index):# or comment_check(lines, index):\n",
" subject = lines[index]\n",
" #pr((subject,'New Subject'))\n",
" current_dic = Or_dict()\n",
" Quick_ref_dic[subject]=current_dic\n",
" elif not(lines[index]):\n",
" index +=1\n",
" continue\n",
" elif check_part_key(lines, index):\n",
" key_part = lines[index]\n",
" index +=1\n",
" continue\n",
" elif comment_check(lines, index):\n",
" comment = lines[index]\n",
" #pr(comment)\n",
" Quick_ref_dic[comment] = None\n",
" elif check_for_range(lines, index):\n",
" pieces = lines[index].split(':')\n",
" parts = []\n",
" tmp = ''\n",
" for part in pieces:\n",
" left = part.count('[')\n",
" right = part.count(']')\n",
" if left>right and not(tmp):\n",
" tmp = part\n",
" #pr(tmp)\n",
" continue\n",
" #pr(part)\n",
" if tmp:\n",
" parts.append(tmp+':'+part)\n",
" tmp=''\n",
" else:\n",
" parts.append(part)\n",
" part_key = parts[0]\n",
" part_key = part_key.strip()\n",
" Quick_ref_dic[subject][part_key]=parts[1]\n",
" elif (\":\" in lines[index] and not('::' in lines[index])):\n",
" parts = lines[index].split(\":\")\n",
" if len(parts)==1:\n",
" parts.append(None)\n",
" if key_part:\n",
" part_key = key_part + \" \" + parts[0]\n",
" key_part = \"\"\n",
" else:\n",
" part_key = parts[0]\n",
" part_key = part_key.strip()\n",
" Quick_ref_dic[subject][part_key]=parts[1]\n",
" #pr('here')\n",
" elif right_column_check(lines, index):\n",
" try:\n",
" key = list(Quick_ref_dic[subject].keys())[-1]\n",
" if Quick_ref_dic[subject][key] == None:\n",
" Quick_ref_dic[subject][key] = lines[index].strip('\\t')\n",
" else:\n",
" Quick_ref_dic[subject][key] = Quick_ref_dic[subject][key]+\" \"+lines[index].strip()\n",
" except:\n",
" pass #break\n",
" \n",
" #if index<15:\n",
" # pr(index)\n",
" #elif index>240:\n",
" # pr(index)\n",
" index+=1\n",
" return Quick_ref_dic"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 26
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"Quick_ref_dic = build_dict(lines)\n",
"pr(Quick_ref_dic)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"{'IPython -- An enhanced Interactive Python - Quick Reference Card': {'obj?, obj??': ' Get help, or more help for object (also works as ?obj, ??obj).',\n",
" '?foo.*abc*': \" List names in 'foo' containing 'abc' in them.\",\n",
" '%magic': \" Information about IPython's 'magic' % functions.\"},\n",
" 'Magic functions are prefixed by % or %%, and typically take their arguments': None,\n",
" 'without parentheses, quotes or even commas for convenience. Line magics take a': None,\n",
" 'single % and cell magics are prefixed with two %%.': None,\n",
" 'Example magic function calls:': {'%alias d ls -F': \" 'd' is now an alias for 'ls -F'\",\n",
" 'alias d ls -F': \" Works if 'alias' not a python name\",\n",
" 'alist = %alias': \" Get list of aliases to 'alist'\",\n",
" 'cd /usr/share': ' Obvious. cd -<tab> to choose from visited dirs.',\n",
" '%cd??': ' See help AND source for magic %cd',\n",
" '%timeit x=10': \" time the 'x=10' statement with high precision. counted. This is an example of a cell magic.\"},\n",
" 'System commands:': {'!cp a.txt b/': ' System command escape, calls os.system()',\n",
" 'cp a.txt b/': ' after %rehashx, most system commands work without !',\n",
" 'cp ${f}.txt $bar': ' Variable expansion in magics and system commands',\n",
" 'files = !ls /usr': ' Capture sytem command output',\n",
" 'files.s, files.l, files.n': ' \"a b c\", [\\'a\\',\\'b\\',\\'c\\'], \\'a\\\\nb\\\\nc\\''},\n",
" 'History:': {'_i, _ii, _iii': ' Previous, next previous, next next previous input',\n",
" '_i4, _ih[2:5]': ' Input history line 4, lines 2-4',\n",
" 'exec _i81': ' Execute input history line #81 again',\n",
" '%rep 81': ' Edit input history line #81',\n",
" '_, __, ___': ' previous, next previous, next next previous output',\n",
" '_dh': ' Directory history',\n",
" '_oh': ' Output history',\n",
" '%hist': \" Command history. '%hist -g foo' search history for 'foo'\"},\n",
" 'Autocall:': {'f 1,2': ' f(1,2) # Off by default, enable with %autocall magic.',\n",
" '/f 1,2': ' f(1,2) (forced autoparen)',\n",
" ',f 1 2': ' f(\"1\",\"2\")',\n",
" ';f 1 2': ' f(\"1 2\")'},\n",
" 'Remember: TAB completion works in many contexts, not just file names': None,\n",
" 'or python names.': None,\n",
" 'The following magic functions are currently available:': {'%alias': ' Define an alias for a system command.',\n",
" '%alias_magic': ' %alias_magic [-l] [-c] name target',\n",
" '%autocall': ' Make functions callable without having to type parentheses.',\n",
" '%automagic': ' Make magic functions callable without having to type the initial %.',\n",
" '%bookmark': \" Manage IPython's bookmark system.\",\n",
" '%cd': ' Change the current working directory.',\n",
" '%clear': ' Clear the terminal.',\n",
" '%colors': ' Switch color scheme for prompts, info system and exception handlers.',\n",
" '%config': ' configure IPython',\n",
" '%connect_info': ' Print information for connecting other clients to this kernel',\n",
" '%debug': ' Activate the interactive debugger in post-mortem mode.',\n",
" '%dhist': ' Print your history of visited directories.',\n",
" '%dirs': ' Return the current directory stack.',\n",
" '%doctest_mode': ' Toggle doctest mode on and off.',\n",
" '%ed': ' Alias for `%edit`.',\n",
" '%edit': ' Bring up an editor and execute the resulting code.',\n",
" '%env': ' List environment variables.',\n",
" '%gui': ' Enable or disable IPython GUI event loop integration.',\n",
" '%hist': ' Print input history (_i<n> variables), with most recent last.',\n",
" '%history': ' Print input history (_i<n> variables), with most recent last.',\n",
" '%install_default_config': ' %install_default_config has been deprecated.',\n",
" '%install_ext': ' Download and install an extension from a URL, e.g.::',\n",
" '%install_profiles': ' %install_profiles has been deprecated.',\n",
" '%killbgscripts': ' Kill all BG processes started by %%script and its family.',\n",
" '%less': ' Show a file through the pager.',\n",
" '%load': ' Load code into the current frontend.',\n",
" '%load_ext': ' Load an IPython extension by its module name.',\n",
" '%loadpy': ' Alias of `%load`',\n",
" '%logoff': ' Temporarily stop logging.',\n",
" '%logon': ' Restart logging.',\n",
" '%logstart': ' Start logging anywhere in a session.',\n",
" '%logstate': ' Print the status of the logging system.',\n",
" '%logstop': ' Fully stop logging and close log file.',\n",
" '%lsmagic': ' List currently available magic functions.',\n",
" '%macro': ' Define a macro for future re-execution. It accepts ranges of history,',\n",
" '%magic': ' Print information about the magic function system.',\n",
" '%man': ' Find the man page for the given command and display in pager.',\n",
" '%more': ' Show a file through the pager.',\n",
" '%notebook': ' %notebook [-e] [-f FORMAT] filename',\n",
" '%page': ' Pretty print the object and display it through a pager.',\n",
" '%pastebin': \" Upload code to Github's Gist paste bin, returning the URL.\",\n",
" '%pdb': ' Control the automatic calling of the pdb interactive debugger.',\n",
" '%pdef': ' Print the definition header for any callable object.',\n",
" '%pdoc': ' Print the docstring for an object.',\n",
" '%pfile': ' Print (or run through pager) the file where an object is defined.',\n",
" '%pinfo': ' Provide detailed information about an object.',\n",
" '%pinfo2': ' Provide extra detailed information about an object.',\n",
" '%popd': ' Change to directory popped off the top of the stack.',\n",
" '%pprint': ' Toggle pretty printing on/off.',\n",
" '%precision': ' Set floating point precision for pretty printing.',\n",
" '%profile': ' Print your currently active IPython profile.',\n",
" '%prun': ' Run a statement through the python code profiler.',\n",
" '%psearch': ' Search for object in namespaces by wildcard.',\n",
" '%psource': ' Print (or run through pager) the source code for an object.',\n",
" '%pushd': ' Place the current dir on stack and change directory.',\n",
" '%pwd': ' Return the current working directory path.',\n",
" '%pycat': ' Show a syntax-highlighted file through a pager.',\n",
" '%pylab': ' Load numpy and matplotlib to work interactively.',\n",
" '%qtconsole': ' Open a qtconsole connected to this kernel.',\n",
" '%quickref': ' Show a quick reference sheet',\n",
" '%quickref_file': ' Show a quick reference sheet',\n",
" '%recall': ' Repeat a command, or get command to input line for editing.',\n",
" '%rehashx': ' Update the alias table with all executable files in $PATH.',\n",
" '%reload_ext': ' Reload an IPython extension by its module name.',\n",
" '%rep': ' Repeat a command, or get command to input line for editing.',\n",
" '%rerun': ' Re-run previous input',\n",
" '%reset': ' Resets the namespace by removing all names defined by the user, if',\n",
" '%reset_selective': ' Resets the namespace by removing names defined by the user.',\n",
" '%run': ' Run the named file inside IPython as a program.',\n",
" '%save': ' Save a set of lines or a macro to a given filename.',\n",
" '%sc': ' Shell capture - run shell command and capture output (DEPRECATED use !).',\n",
" '%store': ' Lightweight persistence for python variables.',\n",
" '%sx': ' Shell execute - run shell command and capture output (!! is short-hand).',\n",
" '%system': ' Shell execute - run shell command and capture output (!! is short-hand).',\n",
" '%tb': ' Print the last traceback with the currently active exception mode.',\n",
" '%time': ' Time execution of a Python statement or expression.',\n",
" '%timeit': ' Time execution of a Python statement or expression',\n",
" '%unalias': ' Remove an alias',\n",
" '%unload_ext': ' Unload an IPython extension by its module name.',\n",
" '%who': ' Print all interactive variables, with some minimal formatting.',\n",
" '%who_ls': ' Return a sorted list of all interactive variables.',\n",
" '%whos': ' Like %who, but gives some extra information about each variable.',\n",
" '%xdel': ' Delete a variable, trying to clear it from anywhere that',\n",
" '%xmode': ' Switch modes for the exception handlers.',\n",
" '%%!': ' Shell execute - run shell command and capture output (!! is short-hand).',\n",
" '%%bash': ' %%bash script magic',\n",
" '%%capture': ' %capture [--no-stderr] [--no-stdout] [output]',\n",
" '%%file': ' %file [-a] filename',\n",
" '%%perl': ' %%perl script magic',\n",
" '%%prun': ' Run a statement through the python code profiler.',\n",
" '%%python3': ' %%python3 script magic',\n",
" '%%ruby': ' %%ruby script magic',\n",
" '%%script': ' %shebang [--proc PROC] [--bg] [--err ERR] [--out OUT]',\n",
" '%%sh': ' %%sh script magic',\n",
" '%%sx': ' Shell execute - run shell command and capture output (!! is short-hand).',\n",
" '%%system': ' Shell execute - run shell command and capture output (!! is short-hand).',\n",
" '%%timeit': ' Time execution of a Python statement or expression'}}\n"
]
}
],
"prompt_number": 27
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"def clean_text(text):\n",
" \"\"\"This function replaces problem characters with HTML friendly characters \"\"\"\n",
" if '<' in text or '>' in text: #allow for the display of <n> and <tab>\n",
" text = text.replace('<','&#60')\n",
" text = text.replace('>','&#62')\n",
" if '$' in text: #ensure that $ renders as a $\n",
" text = text.replace('$','&#xFF04 ') \n",
" #pr(info)\n",
" text= text.strip('\\b')\n",
" return text\n",
"\n",
"def build_HTML_table(QuickRef_Dict):\n",
" \"\"\"This function builds a HTML table of the quickref text like the one seen at \n",
" http://dl.dropboxusercontent.com/u/54552252/ipython-quickref.pdf\"\"\"\n",
" Table = '<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid black;border-collapse:collapse;\">'\n",
" color = 'lightBlue'\n",
" comment_start = True\n",
" for key, value in QuickRef_Dict.items():\n",
" if value!= None:\n",
" background = ' style=\"background-color:'+color+';\" '\n",
" if color == 'lightBlue':\n",
" color = '#D5E0C5'\n",
" else:\n",
" Table+='<tr><td colspan=\"2\"; > </td></tr>'\n",
" text = clean_text(key)\n",
" Table+=\"<tr><td\"+background+' colspan=\"2\"; ><b>'+text+\"</b></td></tr>\"\n",
" for example, explanation in value.items():\n",
" text_left = clean_text(example)\n",
" text_right = clean_text(explanation)\n",
" Table+=\"<tr><td>\"+text_left+\"</td><td>\"+text_right+\"</td></tr>\"\n",
" if not(comment_start):\n",
" comment_start=True\n",
" continue\n",
" else:\n",
" if comment_start:\n",
" Table+='<tr><td colspan=\"2\"; > </td></tr>'\n",
" comment_start = False\n",
" Table +='<tr><td colspan=\"2\"; >'+key+\"</td></tr>\"\n",
" Table +=\"</table>\"\n",
" return Table"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 28
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from IPython.display import HTML\n",
"Table = build_HTML_table(Quick_ref_dic)\n",
"HTML(Table)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\" style=\"border:1px solid black;border-collapse:collapse;\"><tr><td style=\"background-color:lightBlue;\" colspan=\"2\"; ><b>IPython -- An enhanced Interactive Python - Quick Reference Card</b></td></tr><tr><td>obj?, obj??</td><td> Get help, or more help for object (also works as ?obj, ??obj).</td></tr><tr><td>?foo.*abc*</td><td> List names in 'foo' containing 'abc' in them.</td></tr><tr><td>%magic</td><td> Information about IPython's 'magic' % functions.</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td colspan=\"2\"; >Magic functions are prefixed by % or %%, and typically take their arguments</td></tr><tr><td colspan=\"2\"; >without parentheses, quotes or even commas for convenience. Line magics take a</td></tr><tr><td colspan=\"2\"; >single % and cell magics are prefixed with two %%.</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td style=\"background-color:#D5E0C5;\" colspan=\"2\"; ><b>Example magic function calls:</b></td></tr><tr><td>%alias d ls -F</td><td> 'd' is now an alias for 'ls -F'</td></tr><tr><td>alias d ls -F</td><td> Works if 'alias' not a python name</td></tr><tr><td>alist = %alias</td><td> Get list of aliases to 'alist'</td></tr><tr><td>cd /usr/share</td><td> Obvious. cd -&#60tab&#62 to choose from visited dirs.</td></tr><tr><td>%cd??</td><td> See help AND source for magic %cd</td></tr><tr><td>%timeit x=10</td><td> time the 'x=10' statement with high precision. counted. This is an example of a cell magic.</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td style=\"background-color:#D5E0C5;\" colspan=\"2\"; ><b>System commands:</b></td></tr><tr><td>!cp a.txt b/</td><td> System command escape, calls os.system()</td></tr><tr><td>cp a.txt b/</td><td> after %rehashx, most system commands work without !</td></tr><tr><td>cp &#xFF04 {f}.txt &#xFF04 bar</td><td> Variable expansion in magics and system commands</td></tr><tr><td>files = !ls /usr</td><td> Capture sytem command output</td></tr><tr><td>files.s, files.l, files.n</td><td> \"a b c\", ['a','b','c'], 'a\\nb\\nc'</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td style=\"background-color:#D5E0C5;\" colspan=\"2\"; ><b>History:</b></td></tr><tr><td>_i, _ii, _iii</td><td> Previous, next previous, next next previous input</td></tr><tr><td>_i4, _ih[2:5]</td><td> Input history line 4, lines 2-4</td></tr><tr><td>exec _i81</td><td> Execute input history line #81 again</td></tr><tr><td>%rep 81</td><td> Edit input history line #81</td></tr><tr><td>_, __, ___</td><td> previous, next previous, next next previous output</td></tr><tr><td>_dh</td><td> Directory history</td></tr><tr><td>_oh</td><td> Output history</td></tr><tr><td>%hist</td><td> Command history. '%hist -g foo' search history for 'foo'</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td style=\"background-color:#D5E0C5;\" colspan=\"2\"; ><b>Autocall:</b></td></tr><tr><td>f 1,2</td><td> f(1,2) # Off by default, enable with %autocall magic.</td></tr><tr><td>/f 1,2</td><td> f(1,2) (forced autoparen)</td></tr><tr><td>,f 1 2</td><td> f(\"1\",\"2\")</td></tr><tr><td>;f 1 2</td><td> f(\"1 2\")</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td colspan=\"2\"; >Remember: TAB completion works in many contexts, not just file names</td></tr><tr><td colspan=\"2\"; >or python names.</td></tr><tr><td colspan=\"2\"; > </td></tr><tr><td style=\"background-color:#D5E0C5;\" colspan=\"2\"; ><b>The following magic functions are currently available:</b></td></tr><tr><td>%alias</td><td> Define an alias for a system command.</td></tr><tr><td>%alias_magic</td><td> %alias_magic [-l] [-c] name target</td></tr><tr><td>%autocall</td><td> Make functions callable without having to type parentheses.</td></tr><tr><td>%automagic</td><td> Make magic functions callable without having to type the initial %.</td></tr><tr><td>%bookmark</td><td> Manage IPython's bookmark system.</td></tr><tr><td>%cd</td><td> Change the current working directory.</td></tr><tr><td>%clear</td><td> Clear the terminal.</td></tr><tr><td>%colors</td><td> Switch color scheme for prompts, info system and exception handlers.</td></tr><tr><td>%config</td><td> configure IPython</td></tr><tr><td>%connect_info</td><td> Print information for connecting other clients to this kernel</td></tr><tr><td>%debug</td><td> Activate the interactive debugger in post-mortem mode.</td></tr><tr><td>%dhist</td><td> Print your history of visited directories.</td></tr><tr><td>%dirs</td><td> Return the current directory stack.</td></tr><tr><td>%doctest_mode</td><td> Toggle doctest mode on and off.</td></tr><tr><td>%ed</td><td> Alias for `%edit`.</td></tr><tr><td>%edit</td><td> Bring up an editor and execute the resulting code.</td></tr><tr><td>%env</td><td> List environment variables.</td></tr><tr><td>%gui</td><td> Enable or disable IPython GUI event loop integration.</td></tr><tr><td>%hist</td><td> Print input history (_i&#60n&#62 variables), with most recent last.</td></tr><tr><td>%history</td><td> Print input history (_i&#60n&#62 variables), with most recent last.</td></tr><tr><td>%install_default_config</td><td> %install_default_config has been deprecated.</td></tr><tr><td>%install_ext</td><td> Download and install an extension from a URL, e.g.::</td></tr><tr><td>%install_profiles</td><td> %install_profiles has been deprecated.</td></tr><tr><td>%killbgscripts</td><td> Kill all BG processes started by %%script and its family.</td></tr><tr><td>%less</td><td> Show a file through the pager.</td></tr><tr><td>%load</td><td> Load code into the current frontend.</td></tr><tr><td>%load_ext</td><td> Load an IPython extension by its module name.</td></tr><tr><td>%loadpy</td><td> Alias of `%load`</td></tr><tr><td>%logoff</td><td> Temporarily stop logging.</td></tr><tr><td>%logon</td><td> Restart logging.</td></tr><tr><td>%logstart</td><td> Start logging anywhere in a session.</td></tr><tr><td>%logstate</td><td> Print the status of the logging system.</td></tr><tr><td>%logstop</td><td> Fully stop logging and close log file.</td></tr><tr><td>%lsmagic</td><td> List currently available magic functions.</td></tr><tr><td>%macro</td><td> Define a macro for future re-execution. It accepts ranges of history,</td></tr><tr><td>%magic</td><td> Print information about the magic function system.</td></tr><tr><td>%man</td><td> Find the man page for the given command and display in pager.</td></tr><tr><td>%more</td><td> Show a file through the pager.</td></tr><tr><td>%notebook</td><td> %notebook [-e] [-f FORMAT] filename</td></tr><tr><td>%page</td><td> Pretty print the object and display it through a pager.</td></tr><tr><td>%pastebin</td><td> Upload code to Github's Gist paste bin, returning the URL.</td></tr><tr><td>%pdb</td><td> Control the automatic calling of the pdb interactive debugger.</td></tr><tr><td>%pdef</td><td> Print the definition header for any callable object.</td></tr><tr><td>%pdoc</td><td> Print the docstring for an object.</td></tr><tr><td>%pfile</td><td> Print (or run through pager) the file where an object is defined.</td></tr><tr><td>%pinfo</td><td> Provide detailed information about an object.</td></tr><tr><td>%pinfo2</td><td> Provide extra detailed information about an object.</td></tr><tr><td>%popd</td><td> Change to directory popped off the top of the stack.</td></tr><tr><td>%pprint</td><td> Toggle pretty printing on/off.</td></tr><tr><td>%precision</td><td> Set floating point precision for pretty printing.</td></tr><tr><td>%profile</td><td> Print your currently active IPython profile.</td></tr><tr><td>%prun</td><td> Run a statement through the python code profiler.</td></tr><tr><td>%psearch</td><td> Search for object in namespaces by wildcard.</td></tr><tr><td>%psource</td><td> Print (or run through pager) the source code for an object.</td></tr><tr><td>%pushd</td><td> Place the current dir on stack and change directory.</td></tr><tr><td>%pwd</td><td> Return the current working directory path.</td></tr><tr><td>%pycat</td><td> Show a syntax-highlighted file through a pager.</td></tr><tr><td>%pylab</td><td> Load numpy and matplotlib to work interactively.</td></tr><tr><td>%qtconsole</td><td> Open a qtconsole connected to this kernel.</td></tr><tr><td>%quickref</td><td> Show a quick reference sheet</td></tr><tr><td>%quickref_file</td><td> Show a quick reference sheet</td></tr><tr><td>%recall</td><td> Repeat a command, or get command to input line for editing.</td></tr><tr><td>%rehashx</td><td> Update the alias table with all executable files in &#xFF04 PATH.</td></tr><tr><td>%reload_ext</td><td> Reload an IPython extension by its module name.</td></tr><tr><td>%rep</td><td> Repeat a command, or get command to input line for editing.</td></tr><tr><td>%rerun</td><td> Re-run previous input</td></tr><tr><td>%reset</td><td> Resets the namespace by removing all names defined by the user, if</td></tr><tr><td>%reset_selective</td><td> Resets the namespace by removing names defined by the user.</td></tr><tr><td>%run</td><td> Run the named file inside IPython as a program.</td></tr><tr><td>%save</td><td> Save a set of lines or a macro to a given filename.</td></tr><tr><td>%sc</td><td> Shell capture - run shell command and capture output (DEPRECATED use !).</td></tr><tr><td>%store</td><td> Lightweight persistence for python variables.</td></tr><tr><td>%sx</td><td> Shell execute - run shell command and capture output (!! is short-hand).</td></tr><tr><td>%system</td><td> Shell execute - run shell command and capture output (!! is short-hand).</td></tr><tr><td>%tb</td><td> Print the last traceback with the currently active exception mode.</td></tr><tr><td>%time</td><td> Time execution of a Python statement or expression.</td></tr><tr><td>%timeit</td><td> Time execution of a Python statement or expression</td></tr><tr><td>%unalias</td><td> Remove an alias</td></tr><tr><td>%unload_ext</td><td> Unload an IPython extension by its module name.</td></tr><tr><td>%who</td><td> Print all interactive variables, with some minimal formatting.</td></tr><tr><td>%who_ls</td><td> Return a sorted list of all interactive variables.</td></tr><tr><td>%whos</td><td> Like %who, but gives some extra information about each variable.</td></tr><tr><td>%xdel</td><td> Delete a variable, trying to clear it from anywhere that</td></tr><tr><td>%xmode</td><td> Switch modes for the exception handlers.</td></tr><tr><td>%%!</td><td> Shell execute - run shell command and capture output (!! is short-hand).</td></tr><tr><td>%%bash</td><td> %%bash script magic</td></tr><tr><td>%%capture</td><td> %capture [--no-stderr] [--no-stdout] [output]</td></tr><tr><td>%%file</td><td> %file [-a] filename</td></tr><tr><td>%%perl</td><td> %%perl script magic</td></tr><tr><td>%%prun</td><td> Run a statement through the python code profiler.</td></tr><tr><td>%%python3</td><td> %%python3 script magic</td></tr><tr><td>%%ruby</td><td> %%ruby script magic</td></tr><tr><td>%%script</td><td> %shebang [--proc PROC] [--bg] [--err ERR] [--out OUT]</td></tr><tr><td>%%sh</td><td> %%sh script magic</td></tr><tr><td>%%sx</td><td> Shell execute - run shell command and capture output (!! is short-hand).</td></tr><tr><td>%%system</td><td> Shell execute - run shell command and capture output (!! is short-hand).</td></tr><tr><td>%%timeit</td><td> Time execution of a Python statement or expression</td></tr></table>"
],
"output_type": "pyout",
"prompt_number": 29,
"text": [
"<IPython.core.display.HTML at 0x46e24d0>"
]
}
],
"prompt_number": 29
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment