emacs-ipython-notebook/Development Ideas.ipynb

834 lines
88 KiB
Text
Raw Permalink Normal View History

{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Object Inspector"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"Need to get python objects from strings. Is eval the best way?"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"execute-time": [
"2018-11-01T21:27:17.435516Z",
"2018-11-01T21:27:17.469860Z"
],
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import inspect"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"execute-time": [
"2018-11-01T21:33:50.033296Z",
"2018-11-01T21:33:50.064574Z"
],
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import ein"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"ein.pyto"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"execute-time": [
"2018-11-01T21:33:55.629201Z",
"2018-11-01T21:33:55.663747Z"
],
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"['CodeMagics',\n '__builtins__',\n '__cached__',\n '__doc__',\n '__file__',\n '__loader__',\n '__name__',\n '__package__',\n '__spec__',\n '_find_edit_target',\n '_find_edit_target_012',\n '_find_edit_target_013',\n '_find_edit_target_python',\n 'eval_hy_string',\n 'export_nb',\n 'find_source',\n 'print_object_info_for',\n 'run_docstring_examples',\n 'set_figure_size']"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(ein)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"execute-time": [
"2018-11-01T21:34:15.247868Z",
"2018-11-01T21:34:15.283595Z"
],
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"type_name\": \"module\", \"base_class\": \"<class 'module'>\", \"string_form\": \"<module 'inspect' from 'C:\\\\\\\\Users\\\\\\\\mille\\\\\\\\Miniconda3\\\\\\\\lib\\\\\\\\inspect.py'>\", \"namespace\": null, \"length\": null, \"file\": \"c:\\\\users\\\\mille\\\\miniconda3\\\\lib\\\\inspect.py\", \"definition\": null, \"docstring\": \"Get useful information from live Python objects.\\n\\nThis module encapsulates the interface provided by the internal special\\nattributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.\\nIt also provides some help for examining source code and class layout.\\n\\nHere are some of the useful functions provided by this module:\\n\\n ismodule(), isclass(), ismethod(), isfunction(), isgeneratorfunction(),\\n isgenerator(), istraceback(), isframe(), iscode(), isbuiltin(),\\n isroutine() - check object types\\n getmembers() - get members of an object that satisfy a given condition\\n\\n getfile(), getsourcefile(), getsource() - find an object's source code\\n getdoc(), getcomments() - get documentation on an object\\n getmodule() - determine the module that an object came from\\n getclasstree() - arrange classes so as to represent their hierarchy\\n\\n getargvalues(), getcallargs() - get info about function arguments\\n getfullargspec() - same, with support for Python 3 features\\n formatargspec(), formatargvalues() - format an argument spec\\n getouterframes(), getinnerframes() - get info about frames\\n currentframe() - get the current stack frame\\n stack(), trace() - get info about frames on the stack or in a traceback\\n\\n signature() - get a Signature object for the callable\", \"source\": null, \"init_definition\": null, \"class_docstring\": null, \"init_docstring\": null, \"call_def\": null, \"call_docstring\": null, \"ismagic\": false, \"isalias\": false, \"isclass\": null, \"argspec\": null, \"found\": true, \"name\": \"\"}\n"
]
}
],
"source": [
"__import__('ein').print_object_info_for(inspect)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"inspect.B"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"a=10"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"{'error': 'Object ax not found.', 'name': 'ax'}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"name\": \"ax\", \"error\": \"Object ax not found.\"}\n"
]
}
],
"source": [
"__import__('ein_inspector').generate_inspector_data('ax', globals(), locals())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"module"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"mylst = [1, 2, 3]\n",
"type(inspect)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "[1, 2, 3] is not a module, class, method, function, traceback, frame, or code object",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-6-5ce9bb5a72b4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0minspect\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetsourcefile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmylst\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32mc:\\Users\\mille\\Miniconda3\\envs\\anaconda\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetsourcefile\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 658\u001b[0m \u001b[0mReturn\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mno\u001b[0m \u001b[0mway\u001b[0m \u001b[0mcan\u001b[0m \u001b[0mbe\u001b[0m \u001b[0midentified\u001b[0m \u001b[0mto\u001b[0m \u001b[0mget\u001b[0m \u001b[0mthe\u001b[0m \u001b[0msource\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 659\u001b[0m \"\"\"\n\u001b[0;32m--> 660\u001b[0;31m \u001b[0mfilename\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetfile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 661\u001b[0m \u001b[0mall_bytecode_suffixes\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mimportlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmachinery\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDEBUG_BYTECODE_SUFFIXES\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 662\u001b[0m \u001b[0mall_bytecode_suffixes\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[0mimportlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmachinery\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOPTIMIZED_BYTECODE_SUFFIXES\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32mc:\\Users\\mille\\Miniconda3\\envs\\anaconda\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetfile\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 623\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_filename\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 624\u001b[0m raise TypeError('{!r} is not a module, class, method, '\n\u001b[0;32m--> 625\u001b[0;31m 'function, traceback, frame, or code object'.format(object))\n\u001b[0m\u001b[1;32m 626\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 627\u001b[0m \u001b[0mModuleInfo\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnamedtuple\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ModuleInfo'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'name suffix mode module_type'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: [1, 2, 3] is not a module, class, method, function, traceback, frame, or code object"
]
}
],
"source": [
"inspect.getsourcefile(mylst)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"<module 'inspect' from 'c:\\\\Users\\\\mille\\\\Anaconda3\\\\lib\\\\inspect.py'>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eval('inspect')"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"ename": "TypeError",
"evalue": "10 is not a module, class, method, function, traceback, frame, or code object",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-7-01e131c13b92>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0minspect\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgetsource\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32mc:\\Users\\mille\\Anaconda3\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetsource\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 942\u001b[0m \u001b[1;32mor\u001b[0m \u001b[0mcode\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m \u001b[0mThe\u001b[0m \u001b[0msource\u001b[0m \u001b[0mcode\u001b[0m \u001b[1;32mis\u001b[0m \u001b[0mreturned\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0ma\u001b[0m \u001b[0msingle\u001b[0m \u001b[0mstring\u001b[0m\u001b[1;33m.\u001b[0m \u001b[0mAn\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 943\u001b[0m OSError is raised if the source code cannot be retrieved.\"\"\"\n\u001b[0;32m--> 944\u001b[0;31m \u001b[0mlines\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlnum\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetsourcelines\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 945\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[1;34m''\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlines\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 946\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32mc:\\Users\\mille\\Anaconda3\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetsourcelines\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 929\u001b[0m raised if the source code cannot be retrieved.\"\"\"\n\u001b[1;32m 930\u001b[0m \u001b[0mobject\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0munwrap\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 931\u001b[0;31m \u001b[0mlines\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlnum\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfindsource\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 932\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 933\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mismodule\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32mc:\\Users\\mille\\Anaconda3\\lib\\inspect.py\u001b[0m in \u001b[0;36mfindsource\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 742\u001b[0m is raised if the source code cannot be retrieved.\"\"\"\n\u001b[1;32m 743\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m--> 744\u001b[0;31m \u001b[0mfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetsourcefile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 745\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 746\u001b[0m \u001b[1;31m# Invalidate cache if needed.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32mc:\\Users\\mille\\Anaconda3\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetsourcefile\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 658\u001b[0m \u001b[0mReturn\u001b[0m \u001b[1;32mNone\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mno\u001b[0m \u001b[0mway\u001b[0m \u001b[0mcan\u001b[0m \u001b[0mbe\u001b[0m \u001b[0midentified\u001b[0m \u001b[0mto\u001b[0m \u001b[0mget\u001b[0m \u001b[0mthe\u001b[0m \u001b[0msource\u001b[0m\u001b[1;33m.\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 659\u001b[0m \"\"\"\n\u001b[0;32m--> 660\u001b[0;31m \u001b[0mfilename\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mgetfile\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mobject\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 661\u001b[0m \u001b[0mall_bytecode_suffixes\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mimportlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmachinery\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mDEBUG_BYTECODE_SUFFIXES\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 662\u001b[0m \u001b[0mall_bytecode_suffixes\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[0mimportlib\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mmachinery\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mOPTIMIZED_BYTECODE_SUFFIXES\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;32mc:\\Users\\mille\\Anaconda3\\lib\\inspect.py\u001b[0m in \u001b[0;36mgetfile\u001b[0;34m(object)\u001b[0m\n\u001b[1;32m 623\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mobject\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mco_filename\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 624\u001b[0m raise TypeError('{!r} is not a module, class, method, '\n\u001b[0;32m--> 625\u001b[0;31m 'function, traceback, frame, or code object'.format(object))\n\u001b[0m\u001b[1;32m 626\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m 627\u001b[0m \u001b[0mModuleInfo\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mnamedtuple\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'ModuleInfo'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'name suffix mode module_type'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: 10 is not a module, class, method, function, traceback, frame, or code object"
]
}
],
"source": [
"inspect.getsource(a)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inspect.isbuiltin(a)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAD8CAYAAABjAo9vAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzsvVuMHem13/f76l773rvvZDfZvA3nQh2OJM7RSPKR5WMI\nlgwHiQEhhgwE8EOghxhBDOTNQeC3GH5JYDhBAAEOThzkKJdjB4FteWJZ1pzROTOeM9TMcIYzVPPa\nbHZzd/fu3ve9615fHqr3nu5m39jcJHs49QcIkt17V331VdX61rfWf/2XkFKSIkWKFCleHCjPewAp\nUqRIkWK4SA17ihQpUrxgSA17ihQpUrxgSA17ihQpUrxgSA17ihQpUrxgSA17ihQpUrxgSA17ihQp\nUrxgSA17ihQpUrxgSA17ihQpUrxg0J7HScfGxuTc3NzzOHWKFClSfGnx29/+dl1KOX7Q556LYZ+b\nm+Pq1avP49QpUqRI8aWFEOL+YT6XhmJSpEiR4gVDathTpEiR4gVDathTpEiR4gVDathTpEiR4gVD\nathTpEiR4gXDE7NihBAW8A5gbh7vT6SU/+BJj5vi6aLScLi21KDW9SlnDS7PlJgu2c97WClSpBgC\nhuGxe8AfSikvA68DPxRCvDmE46Z4Sqg0HH75+SqOHzGWM3H8iF9+vkql4TzvoaVIkWIIeGLDLhN0\nNv+rb/5J++0dY1xbapC3NPKWjiIEeUsnb2lcW2o876GlSJFiCBhKjF0IoQohPgbWgF9KKd8fxnFT\nPB3Uuj5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Z87jKE4KGb7NIththrD12dLmJpCteNRzuq7\netr7zfdhxjksIzRdsvk
"text/plain": [
"<matplotlib.figure.Figure at 0x2835e82b518>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"ax = plt.plot(np.random.randn(1000), np.random.randn(1000), 'o', alpha=0.3)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x230960ff588>]"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ax"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[<matplotlib.lines.Line2D at 0x230960ff588>]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eval('ax')"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"\"list() -> new empty list\\nlist(iterable) -> new list initialized from iterable's items\""
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inspect.getdoc(ax)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"[('__abs__', <method-wrapper '__abs__' of int object at 0x00000000664B0310>),\n",
" ('__add__', <method-wrapper '__add__' of int object at 0x00000000664B0310>),\n",
" ('__and__', <method-wrapper '__and__' of int object at 0x00000000664B0310>),\n",
" ('__bool__', <method-wrapper '__bool__' of int object at 0x00000000664B0310>),\n",
" ('__ceil__', <function int.__ceil__>),\n",
" ('__class__', int),\n",
" ('__delattr__',\n",
" <method-wrapper '__delattr__' of int object at 0x00000000664B0310>),\n",
" ('__dir__', <function int.__dir__>),\n",
" ('__divmod__',\n",
" <method-wrapper '__divmod__' of int object at 0x00000000664B0310>),\n",
" ('__doc__',\n",
" \"int(x=0) -> integer\\nint(x, base=10) -> integer\\n\\nConvert a number or string to an integer, or return 0 if no arguments\\nare given. If x is a number, return x.__int__(). For floating point\\nnumbers, this truncates towards zero.\\n\\nIf x is not a number or if base is given, then x must be a string,\\nbytes, or bytearray instance representing an integer literal in the\\ngiven base. The literal can be preceded by '+' or '-' and be surrounded\\nby whitespace. The base defaults to 10. Valid bases are 0 and 2-36.\\nBase 0 means to interpret the base from the string as an integer literal.\\n>>> int('0b100', base=0)\\n4\"),\n",
" ('__eq__', <method-wrapper '__eq__' of int object at 0x00000000664B0310>),\n",
" ('__float__',\n",
" <method-wrapper '__float__' of int object at 0x00000000664B0310>),\n",
" ('__floor__', <function int.__floor__>),\n",
" ('__floordiv__',\n",
" <method-wrapper '__floordiv__' of int object at 0x00000000664B0310>),\n",
" ('__format__', <function int.__format__>),\n",
" ('__ge__', <method-wrapper '__ge__' of int object at 0x00000000664B0310>),\n",
" ('__getattribute__',\n",
" <method-wrapper '__getattribute__' of int object at 0x00000000664B0310>),\n",
" ('__getnewargs__', <function int.__getnewargs__>),\n",
" ('__gt__', <method-wrapper '__gt__' of int object at 0x00000000664B0310>),\n",
" ('__hash__', <method-wrapper '__hash__' of int object at 0x00000000664B0310>),\n",
" ('__index__',\n",
" <method-wrapper '__index__' of int object at 0x00000000664B0310>),\n",
" ('__init__', <method-wrapper '__init__' of int object at 0x00000000664B0310>),\n",
" ('__int__', <method-wrapper '__int__' of int object at 0x00000000664B0310>),\n",
" ('__invert__',\n",
" <method-wrapper '__invert__' of int object at 0x00000000664B0310>),\n",
" ('__le__', <method-wrapper '__le__' of int object at 0x00000000664B0310>),\n",
" ('__lshift__',\n",
" <method-wrapper '__lshift__' of int object at 0x00000000664B0310>),\n",
" ('__lt__', <method-wrapper '__lt__' of int object at 0x00000000664B0310>),\n",
" ('__mod__', <method-wrapper '__mod__' of int object at 0x00000000664B0310>),\n",
" ('__mul__', <method-wrapper '__mul__' of int object at 0x00000000664B0310>),\n",
" ('__ne__', <method-wrapper '__ne__' of int object at 0x00000000664B0310>),\n",
" ('__neg__', <method-wrapper '__neg__' of int object at 0x00000000664B0310>),\n",
" ('__new__', <function int.__new__>),\n",
" ('__or__', <method-wrapper '__or__' of int object at 0x00000000664B0310>),\n",
" ('__pos__', <method-wrapper '__pos__' of int object at 0x00000000664B0310>),\n",
" ('__pow__', <method-wrapper '__pow__' of int object at 0x00000000664B0310>),\n",
" ('__radd__', <method-wrapper '__radd__' of int object at 0x00000000664B0310>),\n",
" ('__rand__', <method-wrapper '__rand__' of int object at 0x00000000664B0310>),\n",
" ('__rdivmod__',\n",
" <method-wrapper '__rdivmod__' of int object at 0x00000000664B0310>),\n",
" ('__reduce__', <function int.__reduce__>),\n",
" ('__reduce_ex__', <function int.__reduce_ex__>),\n",
" ('__repr__', <method-wrapper '__repr__' of int object at 0x00000000664B0310>),\n",
" ('__rfloordiv__',\n",
" <method-wrapper '__rfloordiv__' of int object at 0x00000000664B0310>),\n",
" ('__rlshift__',\n",
" <method-wrapper '__rlshift__' of int object at 0x00000000664B0310>),\n",
" ('__rmod__', <method-wrapper '__rmod__' of int object at 0x00000000664B0310>),\n",
" ('__rmul__', <method-wrapper '__rmul__' of int object at 0x00000000664B0310>),\n",
" ('__ror__', <method-wrapper '__ror__' of int object at 0x00000000664B0310>),\n",
" ('__round__', <function int.__round__>),\n",
" ('__rpow__', <method-wrapper '__rpow__' of int object at 0x00000000664B0310>),\n",
" ('__rrshift__',\n",
" <method-wrapper '__rrshift__' of int object at 0x00000000664B0310>),\n",
" ('__rshift__',\n",
" <method-wrapper '__rshift__' of int object at 0x00000000664B0310>),\n",
" ('__rsub__', <method-wrapper '__rsub__' of int object at 0x00000000664B0310>),\n",
" ('__rtruediv__',\n",
" <method-wrapper '__rtruediv__' of int object at 0x00000000664B0310>),\n",
" ('__rxor__', <method-wrapper '__rxor__' of int object at 0x00000000664B0310>),\n",
" ('__setattr__',\n",
" <method-wrapper '__setattr__' of int object at 0x00000000664B0310>),\n",
" ('__sizeof__', <function int.__sizeof__>),\n",
" ('__str__', <method-wrapper '__str__' of int object at 0x00000000664B0310>),\n",
" ('__sub__', <method-wrapper '__sub__' of int object at 0x00000000664B0310>),\n",
" ('__subclasshook__', <function int.__subclasshook__>),\n",
" ('__truediv__',\n",
" <method-wrapper '__truediv__' of int object at 0x00000000664B0310>),\n",
" ('__trunc__', <function int.__trunc__>),\n",
" ('__xor__', <method-wrapper '__xor__' of int object at 0x00000000664B0310>),\n",
" ('bit_length', <function int.bit_length>),\n",
" ('conjugate', <function int.conjugate>),\n",
" ('denominator', 1),\n",
" ('from_bytes', <function int.from_bytes>),\n",
" ('imag', 0),\n",
" ('numerator', 10),\n",
" ('real', 10),\n",
" ('to_bytes', <function int.to_bytes>)]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inspect.getmembers(a)"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Adding Imenu Support"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"## Subheader"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"Seems to be a couple ways of doing this:\n",
"\n",
"1. Configuring a [imenu-generic-expression](http://emacswiki.org/emacs/ImenuMode#toc12) regex's.\n",
"\n",
"2. Redifining imenu-create-index ala python.el.\n"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"def func():\n",
" pass\n",
"\n",
"\n",
"class my_class(object):\n",
" def __init__(self):\n",
" pass\n",
"\n",
"\n",
"class my_class(object):\n",
" def __init__(self):\n",
" pass\n",
"\n",
" def funcme(arg1):\n",
" pass\n",
"\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Another Header"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"ename": "ZeroDivisionError",
"evalue": "division by zero",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-2-05c9758a9c21>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;36m1\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;31mZeroDivisionError\u001b[0m: division by zero"
]
}
],
"source": [
"1/0"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import inspect"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"2"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"1+1"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/plain": [
"<module 'inspect' from 'C:\\\\Users\\\\millejoh\\\\Miniconda3\\\\envs\\\\py34\\\\lib\\\\inspect.py'>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"inspect"
]
},
{
"cell_type": "code",
"execution_count": 0,
"metadata": {
"autoscroll": false,
"collapsed": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
},
"name": "Development Ideas.ipynb"
},
"nbformat": 4,
"nbformat_minor": 0
}