{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": "true"
   },
   "source": [
    "<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Functions\" data-toc-modified-id=\"Functions-1\"><span class=\"toc-item-num\">1&nbsp;&nbsp;</span>Functions</a></span><ul class=\"toc-item\"><li><span><a href=\"#Pass-functions-(Closure)\" data-toc-modified-id=\"Pass-functions-(Closure)-1.1\"><span class=\"toc-item-num\">1.1&nbsp;&nbsp;</span>Pass functions (Closure)</a></span></li><li><span><a href=\"#Dependant-default-values\" data-toc-modified-id=\"Dependant-default-values-1.2\"><span class=\"toc-item-num\">1.2&nbsp;&nbsp;</span>Dependant default values</a></span></li><li><span><a href=\"#Typed-arguments\" data-toc-modified-id=\"Typed-arguments-1.3\"><span class=\"toc-item-num\">1.3&nbsp;&nbsp;</span>Typed arguments</a></span></li></ul></li><li><span><a href=\"#ООП\" data-toc-modified-id=\"ООП-2\"><span class=\"toc-item-num\">2&nbsp;&nbsp;</span>ООП</a></span><ul class=\"toc-item\"><li><span><a href=\"#Class,-instance,-default-(!)-static-vars\" data-toc-modified-id=\"Class,-instance,-default-(!)-static-vars-2.1\"><span class=\"toc-item-num\">2.1&nbsp;&nbsp;</span>Class, instance, default (!) static vars</a></span><ul class=\"toc-item\"><li><span><a href=\"#Instance-variables-by-:\" data-toc-modified-id=\"Instance-variables-by-:-2.1.1\"><span class=\"toc-item-num\">2.1.1&nbsp;&nbsp;</span>Instance variables by :</a></span></li></ul></li><li><span><a href=\"#init-of-parent-must-be-called-always!\" data-toc-modified-id=\"init-of-parent-must-be-called-always!-2.2\"><span class=\"toc-item-num\">2.2&nbsp;&nbsp;</span><strong>init</strong> of parent must be called always!</a></span></li><li><span><a href=\"#Global-constants\" data-toc-modified-id=\"Global-constants-2.3\"><span class=\"toc-item-num\">2.3&nbsp;&nbsp;</span>Global constants</a></span></li><li><span><a href=\"#Call-method-by-its-string-name\" data-toc-modified-id=\"Call-method-by-its-string-name-2.4\"><span class=\"toc-item-num\">2.4&nbsp;&nbsp;</span>Call method by its string name</a></span></li><li><span><a href=\"#getattr\" data-toc-modified-id=\"getattr-2.5\"><span class=\"toc-item-num\">2.5&nbsp;&nbsp;</span>getattr</a></span></li><li><span><a href=\"#Class-instance-by-its-string-name\" data-toc-modified-id=\"Class-instance-by-its-string-name-2.6\"><span class=\"toc-item-num\">2.6&nbsp;&nbsp;</span>Class instance by its string name</a></span><ul class=\"toc-item\"><li><span><a href=\"#function-objectByClassName\" data-toc-modified-id=\"function-objectByClassName-2.6.1\"><span class=\"toc-item-num\">2.6.1&nbsp;&nbsp;</span>function objectByClassName</a></span></li></ul></li></ul></li><li><span><a href=\"#Language-constructions\" data-toc-modified-id=\"Language-constructions-3\"><span class=\"toc-item-num\">3&nbsp;&nbsp;</span>Language constructions</a></span><ul class=\"toc-item\"><li><span><a href=\"#Exceptions\" data-toc-modified-id=\"Exceptions-3.1\"><span class=\"toc-item-num\">3.1&nbsp;&nbsp;</span>Exceptions</a></span></li><li><span><a href=\"#Eval\" data-toc-modified-id=\"Eval-3.2\"><span class=\"toc-item-num\">3.2&nbsp;&nbsp;</span>Eval</a></span></li><li><span><a href=\"#Time-measure\" data-toc-modified-id=\"Time-measure-3.3\"><span class=\"toc-item-num\">3.3&nbsp;&nbsp;</span>Time measure</a></span></li><li><span><a href=\"#String-format\" data-toc-modified-id=\"String-format-3.4\"><span class=\"toc-item-num\">3.4&nbsp;&nbsp;</span>String format</a></span><ul class=\"toc-item\"><li><span><a href=\"#Escape\" data-toc-modified-id=\"Escape-3.4.1\"><span class=\"toc-item-num\">3.4.1&nbsp;&nbsp;</span>Escape</a></span></li></ul></li></ul></li><li><span><a href=\"#Garbage-Collection\" data-toc-modified-id=\"Garbage-Collection-4\"><span class=\"toc-item-num\">4&nbsp;&nbsp;</span>Garbage Collection</a></span></li><li><span><a href=\"#%magic\" data-toc-modified-id=\"%magic-5\"><span class=\"toc-item-num\">5&nbsp;&nbsp;</span>%magic</a></span></li></ul></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Functions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pass functions (Closure)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<function action1 at 0x7fe7a8244488> <class 'function'> True\n",
      "action1 without args\n",
      "<function action2 at 0x7fe7a8244d08> <class 'function'> True\n",
      "a=Avalue\n",
      "<function action3 at 0x7fe7a8a90e18> <class 'function'> True\n",
      "a=AvaL b=bVal\n"
     ]
    }
   ],
   "source": [
    "# :+ http://stackoverflow.com/questions/803616/passing-functions-with-arguments-to-another-function-in-python\n",
    "# http://stackoverflow.com/questions/8954746/python-arguments-as-a-dictionary\n",
    "def perform( fun, *args, **kargs ):\n",
    "    # isinstance(fun, function) will NOT work: http://stackoverflow.com/questions/624926/how-to-detect-whether-a-python-variable-is-a-function\n",
    "    print (fun, type(fun), callable(fun))\n",
    "    fun( *args, **kargs )\n",
    "\n",
    "def action1( ):\n",
    "    print ('action1 without args')\n",
    "    \n",
    "def action2( a ):\n",
    "    print ('a=' + a)\n",
    "\n",
    "def action3( a, b='bbb' ):\n",
    "    print ('a=' + a, 'b=' + b)\n",
    "\n",
    "perform( action1 )\n",
    "perform( action2, 'Avalue' )\n",
    "perform( action3, a='AvaL', b=\"bVal\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dependant default values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'self' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-9-a8a92932291a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mdef\u001b[0m \u001b[0msome\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m3\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m{\u001b[0m\u001b[1;34m'a'\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0ma\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[0m\u001b[0;32m      2\u001b[0m     \u001b[0mprint\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mb\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'self' is not defined"
     ]
    }
   ],
   "source": [
    "def some(a=[1, 2, 3], b={'a': self.a}):\n",
    "    print (a, b)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Typed arguments\n",
    "\n",
    "http://stackoverflow.com/questions/2489669/function-parameter-types-in-python"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:32:35.922540Z",
     "start_time": "2019-02-10T22:32:35.919014Z"
    }
   },
   "outputs": [],
   "source": [
    "def pick(l: list, index: int) -> int:\n",
    "    return l[index]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:32:39.590650Z",
     "start_time": "2019-02-10T22:32:39.586418Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pick([1, 2, 3], 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:32:41.780527Z",
     "start_time": "2019-02-10T22:32:41.449932Z"
    }
   },
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "list indices must be integers or slices, not str",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-33-702d4bf346da>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mpick\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'2'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m<ipython-input-31-2b1a6639c5b1>\u001b[0m in \u001b[0;36mpick\u001b[0;34m(l, index)\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mpick\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mlist\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mindex\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m->\u001b[0m \u001b[0mint\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mindex\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: list indices must be integers or slices, not str"
     ]
    }
   ],
   "source": [
    "pick([1, 2, 3], '2')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# ООП"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "B.a_\n"
     ]
    }
   ],
   "source": [
    "class A:\n",
    "    a_ = 'A.a_'\n",
    "\n",
    "class B(A):\n",
    "    a_ = 'B.a_'\n",
    "\n",
    "b = B()\n",
    "print(b.a_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-04-05T01:57:29.806327",
     "start_time": "2016-04-05T01:57:29.661905"
    }
   },
   "source": [
    "## Class, instance, default (!) static vars\n",
    "\n",
    "**ALL class vars by default static!!!**\n",
    "\n",
    "* http://stackoverflow.com/questions/11040438/class-variables-is-shared-across-all-instances-in-python\n",
    "* http://stackoverflow.com/questions/68645/static-class-variables-in-python\n",
    "* https://docs.python.org/2/tutorial/classes.html#class-objects"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:25:34.185791Z",
     "start_time": "2019-02-10T22:25:34.170287Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['newlist']"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> class A():\n",
    "...     var = 0\n",
    "...     list = []\n",
    "...     def __init__(self):\n",
    "...         self.list1 = []\n",
    "...\n",
    ">>> a = A()\n",
    ">>> b = A()\n",
    ">>> a.var\n",
    "0\n",
    ">>> a.list\n",
    "[]\n",
    ">>> b.var\n",
    "0\n",
    ">>> b.list\n",
    "[]\n",
    ">>> a.var = 1\n",
    ">>> b.var\n",
    "0\n",
    ">>> a.list.append('hello')\n",
    ">>> b.list\n",
    "['hello']\n",
    ">>> b.list = ['newlist']\n",
    ">>> a.list\n",
    "['hello']\n",
    ">>> b.list\n",
    "['newlist']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:25:22.887829Z",
     "start_time": "2019-02-10T22:25:22.884839Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['one']"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a.list1.append('one')\n",
    "a.list1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:25:25.098698Z",
     "start_time": "2019-02-10T22:25:25.089867Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b.list1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:26:11.396675Z",
     "start_time": "2019-02-10T22:26:11.393736Z"
    }
   },
   "outputs": [],
   "source": [
    "class Test(object):\n",
    "    _i = 3\n",
    "    @property\n",
    "    def i(self):\n",
    "        return self._i\n",
    "    @i.setter\n",
    "    def i(self,val):\n",
    "        self._i = val"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:26:13.721311Z",
     "start_time": "2019-02-10T22:26:13.714180Z"
    }
   },
   "outputs": [],
   "source": [
    "x1 = Test()\n",
    "x2 = Test()\n",
    "x1.i = 50\n",
    "assert x2.i == 3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Instance variables by :"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:31:47.262336Z",
     "start_time": "2019-02-10T22:31:47.258602Z"
    }
   },
   "outputs": [],
   "source": [
    "# https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html#classes\n",
    "class B():\n",
    "    var_untyped: 0\n",
    "    var_str: str = \"4\"\n",
    "\n",
    "    def __init__(self):\n",
    "        # Note, Types NOT enforced!\n",
    "        # See https://www.python.org/dev/peps/pep-0526/#non-goals, quoting:\n",
    "        #\n",
    "        # It should also be emphasized that Python will remain a dynamically typed language, and the authors\n",
    "        # have no desire to ever make type hints mandatory, even by convention.\n",
    "        # Type annotations should not be confused with variable declarations in statically typed languages.\n",
    "        # The goal of annotation syntax is to provide an easy way to specify structured type metadata for third\n",
    "        # party tools.\n",
    "        self.var_str = 5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:50:44.350530Z",
     "start_time": "2019-02-10T22:50:44.347138Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "b = B()\n",
    "print(b.var_str)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-02-10T22:29:14.336525Z",
     "start_time": "2019-02-10T22:29:14.122366Z"
    }
   },
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "type object 'B' has no attribute 'var_str'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-19-f29d20d363f9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mB\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvar_str\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mAttributeError\u001b[0m: type object 'B' has no attribute 'var_str'"
     ]
    }
   ],
   "source": [
    "print(B.var_str)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## __init__ of parent must be called always!\n",
    "\n",
    "* http://stackoverflow.com/questions/753640/inheritance-and-overriding-init-in-python\n",
    "* http://stackoverflow.com/questions/6535832/python-inherit-the-superclass-init\n",
    "* http://stackoverflow.com/questions/3782827/why-arent-pythons-superclass-init-methods-automatically-invoked !!!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-04-05T02:32:16.928480",
     "start_time": "2016-04-05T02:32:16.923537"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "B.__init__\n"
     ]
    }
   ],
   "source": [
    "class A:\n",
    "    def __init__(self):\n",
    "        print ('A.__init__')\n",
    "\n",
    "class B(A):\n",
    "    def __init__(self):\n",
    "        print ('B.__init__')\n",
    "\n",
    "b = B()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-04-05T02:32:18.640004",
     "start_time": "2016-04-05T02:32:18.635793"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A.__init__\n",
      "B.__init__\n"
     ]
    }
   ],
   "source": [
    "class B(A):\n",
    "    def __init__(self):\n",
    "        super().__init__() # <-++\n",
    "        print ('B.__init__')\n",
    "\n",
    "b = B()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-04-05T02:33:19.558355",
     "start_time": "2016-04-05T02:33:19.546718"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A.__init__\n",
      "B.__init__\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "('self.A__init', 'self.B__init')"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "class A:\n",
    "    static = 'A.static'\n",
    "\n",
    "    def __init__(self):\n",
    "        print ('A.__init__')\n",
    "        self.A__init = 'self.A__init'\n",
    "\n",
    "class B(A):\n",
    "    def __init__(self):\n",
    "        super().__init__() # <-++\n",
    "        print ('B.__init__')\n",
    "        self.B__init = 'self.B__init'\n",
    "\n",
    "b = B()\n",
    "(b.A__init, b.B__init)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Global constants"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "8\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "SOME_CONST=8\n",
    "\n",
    "class C:\n",
    "    def m(self):\n",
    "        print (SOME_CONST)\n",
    "\n",
    "c = C()\n",
    "c.m()\n",
    "SOME_CONST=4\n",
    "c.m()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Call method by its string name\n",
    "\n",
    "http://stackoverflow.com/questions/3521715/call-a-python-method-by-name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "bar1\n"
     ]
    }
   ],
   "source": [
    "class Foo:\n",
    "    def bar1(self):\n",
    "        print ('bar1')\n",
    "    def bar2(self):\n",
    "        print ('bar2')\n",
    "\n",
    "def callMethod(o, name):\n",
    "    getattr(o, name)()\n",
    "\n",
    "\n",
    "f = Foo()\n",
    "callMethod(f, 'bar1')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## getattr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'B.a_'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getattr(b, 'a_')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'B.a_'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getattr(b, 'not_existent', b.a_)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## Class instance by its string name\n",
    "\n",
    "http://stackoverflow.com/questions/4821104/python-dynamic-instantiation-from-string-name-of-a-class-in-dynamically-imported"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MinMaxScaler(copy=True, feature_range=(0, 1))"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "className = 'sklearn.preprocessing.MinMaxScaler'\n",
    "\n",
    "import importlib\n",
    "module_name, class_name = className.rsplit(\".\", 1)\n",
    "MyClass = getattr(importlib.import_module(module_name), class_name)\n",
    "instance = MyClass()\n",
    "instance"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### function objectByClassName"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "MinMaxScaler(copy=True, feature_range=(0, 1))"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import importlib\n",
    "\n",
    "def objectByClassName(className, *args, **kargs):\n",
    "    module_name, class_name = className.rsplit(\".\", 1)\n",
    "    MyClass = getattr(importlib.import_module(module_name), class_name)\n",
    "    return MyClass(*args, **kargs)\n",
    "\n",
    "# Example:\n",
    "objectByClassName('sklearn.preprocessing.MinMaxScaler')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Language constructions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Exceptions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n",
      "...continue\n",
      "Exception happened 2\n",
      "True\n",
      "...continue\n"
     ]
    }
   ],
   "source": [
    "x = {1: False, 3: True} # no 2!\n",
    "\n",
    "for v in [1,2,3]:\n",
    "    try:\n",
    "        print (x[v])\n",
    "        print ('...continue')\n",
    "    except Exception as e:\n",
    "        print ('Exception happened', e)\n",
    "        pass"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Eval"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "eval('2 + 3')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Normalizer(copy=True, norm='max')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.preprocessing import *\n",
    "eval(\"Normalizer(norm='max')\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Time measure"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# Borrowed from https://gist.github.com/zed/5073409\n",
    "# (http://stackoverflow.com/questions/15176619/timing-the-cpu-time-of-a-python-program)\n",
    "# implementation of process_time function for Python 2 (backport)\n",
    "import ctypes\n",
    "import errno\n",
    "from ctypes.util import find_library\n",
    "from functools import partial\n",
    "\n",
    "CLOCK_PROCESS_CPUTIME_ID = 2  # time.h\n",
    "CLOCK_MONOTONIC_RAW = 4\n",
    "\n",
    "clockid_t = ctypes.c_int\n",
    "time_t = ctypes.c_long\n",
    "\n",
    "class timespec(ctypes.Structure):\n",
    "    _fields_ = [\n",
    "        ('tv_sec', time_t),         # seconds\n",
    "        ('tv_nsec', ctypes.c_long)  # nanoseconds\n",
    "    ]\n",
    "_clock_gettime = ctypes.CDLL(find_library('rt'), use_errno=True).clock_gettime\n",
    "_clock_gettime.argtypes = [clockid_t, ctypes.POINTER(timespec)]\n",
    "\n",
    "\n",
    "def clock_gettime(clk_id):\n",
    "    tp = timespec()\n",
    "    if _clock_gettime(clk_id, ctypes.byref(tp)) < 0:\n",
    "        err = ctypes.get_errno()\n",
    "        msg = errno.errorcode[err]\n",
    "        if err == errno.EINVAL:\n",
    "            msg += (\" The clk_id specified is not supported on this system\"\n",
    "                    \" clk_id=%r\") % (clk_id,)\n",
    "        raise OSError(err, msg)\n",
    "    return tp.tv_sec + tp.tv_nsec * 1e-9\n",
    "\n",
    "try:\n",
    "    from time import perf_counter, process_time\n",
    "except ImportError:  # Python <3.3\n",
    "    perf_counter = partial(clock_gettime, CLOCK_MONOTONIC_RAW)\n",
    "    perf_counter.__name__ = 'perf_counter'\n",
    "    process_time = partial(clock_gettime, CLOCK_PROCESS_CPUTIME_ID)\n",
    "    process_time.__name__ = 'process_time'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## String format"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Escape\n",
    "http://stackoverflow.com/questions/5466451/how-can-i-print-a-literal-characters-in-python-string-and-also-use-format"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2016-04-07T00:51:32.652412",
     "start_time": "2016-04-07T00:51:32.605217"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'test_1_{}'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'test_{}_{{}}'.format(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Garbage Collection\n",
    "\n",
    "https://docs.python.org/3/library/gc.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import gc\n",
    "gc.garbage"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(ctypes.c_char, 16),\n",
       " (_ctypes.Array,),\n",
       " ctypes.c_char_Array_16,\n",
       " <attribute '__dict__' of 'c_char_Array_16' objects>,\n",
       " <attribute '__weakref__' of 'c_char_Array_16' objects>,\n",
       " (ctypes.c_char_Array_16, _ctypes.Array, _ctypes._CData, object),\n",
       " <weakref at 0x7f51c00ba728; to '_ctypes.PyCArrayType' at 0x55b8f5467248 (c_char_Array_16)>,\n",
       " {'__dict__': <attribute '__dict__' of 'c_char_Array_16' objects>,\n",
       "  '__doc__': None,\n",
       "  '__module__': 'ctypes',\n",
       "  '__weakref__': <attribute '__weakref__' of 'c_char_Array_16' objects>,\n",
       "  '_length_': 16,\n",
       "  '_type_': ctypes.c_char,\n",
       "  'raw': <attribute 'raw' of 'c_char_Array_16' objects>,\n",
       "  'value': <attribute 'value' of 'c_char_Array_16' objects>},\n",
       " <attribute 'raw' of 'c_char_Array_16' objects>,\n",
       " <attribute 'value' of 'c_char_Array_16' objects>,\n",
       " <weakproxy at 0x7f51c00ba958 to _ctypes.PyCArrayType at 0x55b8f5467248>,\n",
       " <IPython.core.formatters.IPythonDisplayFormatter at 0x7f51c006e470>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'text/plain',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_ipython_display_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'text/plain',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_ipython_display_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.PlainTextFormatter at 0x7f51c006e4a8>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {('collections',\n",
       "     'Counter'): <function IPython.lib.pretty._counter_pprint>,\n",
       "    ('collections',\n",
       "     'OrderedDict'): <function IPython.lib.pretty._ordereddict_pprint>,\n",
       "    ('collections',\n",
       "     'defaultdict'): <function IPython.lib.pretty._defaultdict_pprint>,\n",
       "    ('collections', 'deque'): <function IPython.lib.pretty._deque_pprint>},\n",
       "   'enabled': True,\n",
       "   'float_format': '%r',\n",
       "   'float_precision': '',\n",
       "   'format_type': 'text/plain',\n",
       "   'max_seq_length': 1000,\n",
       "   'max_width': 79,\n",
       "   'newline': '\\n',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'pprint': True,\n",
       "   'print_method': '_repr_pretty_',\n",
       "   'singleton_printers': {139989402110976: <function IPython.lib.pretty._repr_pprint>,\n",
       "    139989402111008: <function IPython.lib.pretty._repr_pprint>,\n",
       "    139989402204240: <function IPython.lib.pretty._repr_pprint>,\n",
       "    139989402204656: <function IPython.lib.pretty._repr_pprint>,\n",
       "    139989402216560: <function IPython.lib.pretty._repr_pprint>},\n",
       "   'type_printers': {tuple: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "    frozenset: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "    method: <function IPython.lib.pretty._repr_pprint>,\n",
       "    float: <function IPython.core.formatters.PlainTextFormatter._type_printers_default.<locals>.<lambda>>,\n",
       "    datetime.datetime: <function IPython.lib.pretty._repr_pprint>,\n",
       "    set: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "    BaseException: <function IPython.lib.pretty._exception_pprint>,\n",
       "    function: <function IPython.lib.pretty._function_pprint>,\n",
       "    _sre.SRE_Pattern: <function IPython.lib.pretty._re_pattern_pprint>,\n",
       "    dict: <function IPython.lib.pretty._dict_pprinter_factory.<locals>.inner>,\n",
       "    builtin_function_or_method: <function IPython.lib.pretty._function_pprint>,\n",
       "    slice: <function IPython.lib.pretty._repr_pprint>,\n",
       "    str: <function IPython.lib.pretty._repr_pprint>,\n",
       "    range: <function IPython.lib.pretty._repr_pprint>,\n",
       "    type: <function IPython.lib.pretty._type_pprint>,\n",
       "    list: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "    super: <function IPython.lib.pretty._super_pprint>,\n",
       "    bytes: <function IPython.lib.pretty._repr_pprint>,\n",
       "    int: <function IPython.lib.pretty._repr_pprint>,\n",
       "    datetime.timedelta: <function IPython.lib.pretty._repr_pprint>},\n",
       "   'verbose': False}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {('collections',\n",
       "    'Counter'): <function IPython.lib.pretty._counter_pprint>,\n",
       "   ('collections',\n",
       "    'OrderedDict'): <function IPython.lib.pretty._ordereddict_pprint>,\n",
       "   ('collections',\n",
       "    'defaultdict'): <function IPython.lib.pretty._defaultdict_pprint>,\n",
       "   ('collections', 'deque'): <function IPython.lib.pretty._deque_pprint>},\n",
       "  'enabled': True,\n",
       "  'float_format': '%r',\n",
       "  'float_precision': '',\n",
       "  'format_type': 'text/plain',\n",
       "  'max_seq_length': 1000,\n",
       "  'max_width': 79,\n",
       "  'newline': '\\n',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'pprint': True,\n",
       "  'print_method': '_repr_pretty_',\n",
       "  'singleton_printers': {139989402110976: <function IPython.lib.pretty._repr_pprint>,\n",
       "   139989402111008: <function IPython.lib.pretty._repr_pprint>,\n",
       "   139989402204240: <function IPython.lib.pretty._repr_pprint>,\n",
       "   139989402204656: <function IPython.lib.pretty._repr_pprint>,\n",
       "   139989402216560: <function IPython.lib.pretty._repr_pprint>},\n",
       "  'type_printers': {tuple: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "   frozenset: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "   method: <function IPython.lib.pretty._repr_pprint>,\n",
       "   float: <function IPython.core.formatters.PlainTextFormatter._type_printers_default.<locals>.<lambda>>,\n",
       "   datetime.datetime: <function IPython.lib.pretty._repr_pprint>,\n",
       "   set: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "   BaseException: <function IPython.lib.pretty._exception_pprint>,\n",
       "   function: <function IPython.lib.pretty._function_pprint>,\n",
       "   _sre.SRE_Pattern: <function IPython.lib.pretty._re_pattern_pprint>,\n",
       "   dict: <function IPython.lib.pretty._dict_pprinter_factory.<locals>.inner>,\n",
       "   builtin_function_or_method: <function IPython.lib.pretty._function_pprint>,\n",
       "   slice: <function IPython.lib.pretty._repr_pprint>,\n",
       "   str: <function IPython.lib.pretty._repr_pprint>,\n",
       "   range: <function IPython.lib.pretty._repr_pprint>,\n",
       "   type: <function IPython.lib.pretty._type_pprint>,\n",
       "   list: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "   super: <function IPython.lib.pretty._super_pprint>,\n",
       "   bytes: <function IPython.lib.pretty._repr_pprint>,\n",
       "   int: <function IPython.lib.pretty._repr_pprint>,\n",
       "   datetime.timedelta: <function IPython.lib.pretty._repr_pprint>},\n",
       "  'verbose': False},\n",
       " {'application/javascript': <IPython.core.formatters.JavascriptFormatter at 0x7f51c006e390>,\n",
       "  'application/json': <IPython.core.formatters.JSONFormatter at 0x7f51c006e358>,\n",
       "  'application/pdf': <IPython.core.formatters.PDFFormatter at 0x7f51c006e5c0>,\n",
       "  'image/jpeg': <IPython.core.formatters.JPEGFormatter at 0x7f51c006e668>,\n",
       "  'image/png': <IPython.core.formatters.PNGFormatter at 0x7f51c006e518>,\n",
       "  'image/svg+xml': <IPython.core.formatters.SVGFormatter at 0x7f51c006e5f8>,\n",
       "  'text/html': <IPython.core.formatters.HTMLFormatter at 0x7f51c006e438>,\n",
       "  'text/latex': <IPython.core.formatters.LatexFormatter at 0x7f51c006e630>,\n",
       "  'text/markdown': <IPython.core.formatters.MarkdownFormatter at 0x7f51c006e588>,\n",
       "  'text/plain': <IPython.core.formatters.PlainTextFormatter at 0x7f51c006e4a8>},\n",
       " <IPython.core.formatters.HTMLFormatter at 0x7f51c006e438>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'text/html',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_html_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'text/html',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_html_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.MarkdownFormatter at 0x7f51c006e588>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'text/markdown',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_markdown_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'text/markdown',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_markdown_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.SVGFormatter at 0x7f51c006e5f8>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'image/svg+xml',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_svg_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'image/svg+xml',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_svg_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.PNGFormatter at 0x7f51c006e518>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'image/png',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_png_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'image/png',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_png_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.PDFFormatter at 0x7f51c006e5c0>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'application/pdf',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_pdf_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'application/pdf',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_pdf_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.JPEGFormatter at 0x7f51c006e668>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'image/jpeg',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_jpeg_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'image/jpeg',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_jpeg_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.LatexFormatter at 0x7f51c006e630>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'text/latex',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_latex_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'text/latex',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_latex_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.JSONFormatter at 0x7f51c006e358>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'application/json',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_json_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'application/json',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_json_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " <IPython.core.formatters.JavascriptFormatter at 0x7f51c006e390>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'deferred_printers': {},\n",
       "   'enabled': True,\n",
       "   'format_type': 'application/javascript',\n",
       "   'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'print_method': '_repr_javascript_',\n",
       "   'singleton_printers': {},\n",
       "   'type_printers': {}}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'deferred_printers': {},\n",
       "  'enabled': True,\n",
       "  'format_type': 'application/javascript',\n",
       "  'parent': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'print_method': '_repr_javascript_',\n",
       "  'singleton_printers': {},\n",
       "  'type_printers': {}},\n",
       " {139989402110976: <function IPython.lib.pretty._repr_pprint>,\n",
       "  139989402111008: <function IPython.lib.pretty._repr_pprint>,\n",
       "  139989402204240: <function IPython.lib.pretty._repr_pprint>,\n",
       "  139989402204656: <function IPython.lib.pretty._repr_pprint>,\n",
       "  139989402216560: <function IPython.lib.pretty._repr_pprint>},\n",
       " <cell at 0x7f51c0149fd8: PlainTextFormatter object at 0x7f51c006e4a8>,\n",
       " {tuple: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "  frozenset: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "  method: <function IPython.lib.pretty._repr_pprint>,\n",
       "  float: <function IPython.core.formatters.PlainTextFormatter._type_printers_default.<locals>.<lambda>>,\n",
       "  datetime.datetime: <function IPython.lib.pretty._repr_pprint>,\n",
       "  set: <function IPython.lib.pretty._set_pprinter_factory.<locals>.inner>,\n",
       "  BaseException: <function IPython.lib.pretty._exception_pprint>,\n",
       "  function: <function IPython.lib.pretty._function_pprint>,\n",
       "  _sre.SRE_Pattern: <function IPython.lib.pretty._re_pattern_pprint>,\n",
       "  dict: <function IPython.lib.pretty._dict_pprinter_factory.<locals>.inner>,\n",
       "  builtin_function_or_method: <function IPython.lib.pretty._function_pprint>,\n",
       "  slice: <function IPython.lib.pretty._repr_pprint>,\n",
       "  str: <function IPython.lib.pretty._repr_pprint>,\n",
       "  range: <function IPython.lib.pretty._repr_pprint>,\n",
       "  type: <function IPython.lib.pretty._type_pprint>,\n",
       "  list: <function IPython.lib.pretty._seq_pprinter_factory.<locals>.inner>,\n",
       "  super: <function IPython.lib.pretty._super_pprint>,\n",
       "  bytes: <function IPython.lib.pretty._repr_pprint>,\n",
       "  int: <function IPython.lib.pretty._repr_pprint>,\n",
       "  datetime.timedelta: <function IPython.lib.pretty._repr_pprint>},\n",
       " (<cell at 0x7f51c0149fd8: PlainTextFormatter object at 0x7f51c006e4a8>,),\n",
       " <function IPython.core.formatters.PlainTextFormatter._type_printers_default.<locals>.<lambda>>,\n",
       " {('collections', 'Counter'): <function IPython.lib.pretty._counter_pprint>,\n",
       "  ('collections',\n",
       "   'OrderedDict'): <function IPython.lib.pretty._ordereddict_pprint>,\n",
       "  ('collections',\n",
       "   'defaultdict'): <function IPython.lib.pretty._defaultdict_pprint>,\n",
       "  ('collections', 'deque'): <function IPython.lib.pretty._deque_pprint>},\n",
       " ['pick([1, 2, 3], 2)\\n'],\n",
       " (19,\n",
       "  1458427476.3872025,\n",
       "  ['pick([1, 2, 3], 2)\\n'],\n",
       "  '<ipython-input-15-af0e982457fa>'),\n",
       " <weakref at 0x7f51c0057368; dead>,\n",
       " [],\n",
       " <frame at 0x55b8f5478ba8>,\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 1),\n",
       " <frame at 0x7f51c0051448>,\n",
       " <frame at 0x7f51b4003988>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c00d3d38>,\n",
       " [<zmq.sugar.frame.Frame at 0x7f51c00d3d38>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c00591b8>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059270>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059328>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c00593e0>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059498>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059550>],\n",
       " <zmq.sugar.frame.Frame at 0x7f51c00591b8>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059270>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059328>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c00593e0>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059498>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059550>,\n",
       " <frame at 0x55b8f5453b18>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c00d3d38>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00591b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00593e0>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059498>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059550>],),\n",
       " ((), None),\n",
       " <frame at 0x7f51b4002c68>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c00d3d38>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00591b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00593e0>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059498>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059550>],),\n",
       " <frame at 0x7f51c004e9a8>,\n",
       " <frame at 0x55b8f5453e48>,\n",
       " [b'C7DE1DB7B2DD4D1FA63D6B1AAEF49737'],\n",
       " {'buffers': [],\n",
       "  'content': {'allow_stdin': True,\n",
       "   'code': \"pick([1, 2, 3], '2')\",\n",
       "   'silent': False,\n",
       "   'stop_on_error': True,\n",
       "   'store_history': True,\n",
       "   'user_expressions': {}},\n",
       "  'header': {'date': '2016-03-20T01:44:44.341120',\n",
       "   'msg_id': '087198E1BE4D48298E906BF6971E9E9A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': 'C7DE1DB7B2DD4D1FA63D6B1AAEF49737',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'metadata': {},\n",
       "  'msg_id': '087198E1BE4D48298E906BF6971E9E9A',\n",
       "  'msg_type': 'execute_request',\n",
       "  'parent_header': {}},\n",
       " {'allow_stdin': True,\n",
       "  'code': \"pick([1, 2, 3], '2')\",\n",
       "  'silent': False,\n",
       "  'stop_on_error': True,\n",
       "  'store_history': True,\n",
       "  'user_expressions': {}},\n",
       " [],\n",
       " <frame at 0x55b8f5445bb8>,\n",
       " <frame at 0x55b8f54540e8>,\n",
       " <frame at 0x55b8f5455958>,\n",
       " <cell at 0x7f51c00bd768: ExecutionResult object at 0x7f51c006bfd0>,\n",
       " <IPython.core.interactiveshell.ExecutionResult at 0x7f51c006bfd0>,\n",
       " (<cell at 0x7f51c00bd768: ExecutionResult object at 0x7f51c006bfd0>,),\n",
       " <function IPython.core.interactiveshell.InteractiveShell.run_cell.<locals>.error_before_exec>,\n",
       " [\"pick([1, 2, 3], '2')\\n\"],\n",
       " (21,\n",
       "  1458427484.3528702,\n",
       "  [\"pick([1, 2, 3], '2')\\n\"],\n",
       "  '<ipython-input-16-48b0526ba3da>'),\n",
       " <_ast.Module at 0x7f51c006b9b0>,\n",
       " [<_ast.Expr at 0x7f51c006b9e8>],\n",
       " <_ast.Expr at 0x7f51c006b9e8>,\n",
       " <_ast.Call at 0x7f51c006bc88>,\n",
       " <_ast.Name at 0x7f51c006b128>,\n",
       " {'col_offset': 0,\n",
       "  'ctx': <_ast.Load at 0x7f51c972e630>,\n",
       "  'id': 'pick',\n",
       "  'lineno': 1},\n",
       " {'args': [<_ast.List at 0x7f51c006b0b8>, <_ast.Str at 0x7f51c006b6a0>],\n",
       "  'col_offset': 0,\n",
       "  'func': <_ast.Name at 0x7f51c006b128>,\n",
       "  'keywords': [],\n",
       "  'kwargs': None,\n",
       "  'lineno': 1,\n",
       "  'starargs': None},\n",
       " [<_ast.List at 0x7f51c006b0b8>, <_ast.Str at 0x7f51c006b6a0>],\n",
       " <_ast.List at 0x7f51c006b0b8>,\n",
       " [<_ast.Num at 0x7f51c006b048>,\n",
       "  <_ast.Num at 0x7f51c006b198>,\n",
       "  <_ast.Num at 0x7f51c006bc18>],\n",
       " <_ast.Num at 0x7f51c006b048>,\n",
       " <_ast.Num at 0x7f51c006b198>,\n",
       " <_ast.Num at 0x7f51c006bc18>,\n",
       " {'col_offset': 5,\n",
       "  'ctx': <_ast.Load at 0x7f51c972e630>,\n",
       "  'elts': [<_ast.Num at 0x7f51c006b048>,\n",
       "   <_ast.Num at 0x7f51c006b198>,\n",
       "   <_ast.Num at 0x7f51c006bc18>],\n",
       "  'lineno': 1},\n",
       " <_ast.Str at 0x7f51c006b6a0>,\n",
       " [],\n",
       " {'col_offset': 0, 'lineno': 1, 'value': <_ast.Call at 0x7f51c006bc88>},\n",
       " {'body': [<_ast.Expr at 0x7f51c006b9e8>]},\n",
       " <frame at 0x55b8f5479628>,\n",
       " [],\n",
       " [<_ast.Expr at 0x7f51c006b9e8>],\n",
       " [<_ast.Expr at 0x7f51c006b9e8>],\n",
       " <_ast.Interactive at 0x7f51c006b2b0>,\n",
       " {'body': [<_ast.Expr at 0x7f51c006b9e8>]},\n",
       " ('pick',),\n",
       " (1, 2, 3, '2', None),\n",
       " <frame at 0x55b8f54798f8>,\n",
       " <frame at 0x7f51c005c630>,\n",
       " [1, 2, 3],\n",
       " <frame at 0x55b8f545d198>,\n",
       " <traceback at 0x7f51c0076808>,\n",
       " <traceback at 0x7f51c0085148>,\n",
       " <traceback at 0x7f51c0085108>,\n",
       " ('list indices must be integers, not str',),\n",
       " TypeError('list indices must be integers, not str'),\n",
       " {'error_in_exec': TypeError('list indices must be integers, not str'),\n",
       "  'execution_count': 16},\n",
       " <weakref at 0x7f51c0064908; dead>,\n",
       " {'index': '2', 'l': [1, 2, 3]},\n",
       " ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "  '\\x1b[1;31mTypeError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "  \"\\x1b[1;32m<ipython-input-16-48b0526ba3da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[1;32m----> 1\\x1b[1;33m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;34m'2'\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\",\n",
       "  '\\x1b[1;32m<ipython-input-14-345e48108d28>\\x1b[0m in \\x1b[0;36mpick\\x1b[1;34m(l, index)\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mdef\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[0ml\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mlist\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[0mindex\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m)\\x1b[0m \\x1b[1;33m->\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m:\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m     \\x1b[1;32mreturn\\x1b[0m \\x1b[0ml\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[0mindex\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\\x1b[0;32m      3\\x1b[0m \\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0;32m      4\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n',\n",
       "  '\\x1b[1;31mTypeError\\x1b[0m: list indices must be integers, not str'],\n",
       " {'ename': 'TypeError',\n",
       "  'engine_info': {'engine_id': -1,\n",
       "   'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'method': 'execute'},\n",
       "  'evalue': 'list indices must be integers, not str',\n",
       "  'execution_count': 16,\n",
       "  'payload': [],\n",
       "  'status': 'error',\n",
       "  'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "   '\\x1b[1;31mTypeError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "   \"\\x1b[1;32m<ipython-input-16-48b0526ba3da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[1;32m----> 1\\x1b[1;33m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;34m'2'\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\",\n",
       "   '\\x1b[1;32m<ipython-input-14-345e48108d28>\\x1b[0m in \\x1b[0;36mpick\\x1b[1;34m(l, index)\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mdef\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[0ml\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mlist\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[0mindex\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m)\\x1b[0m \\x1b[1;33m->\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m:\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m     \\x1b[1;32mreturn\\x1b[0m \\x1b[0ml\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[0mindex\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\\x1b[0;32m      3\\x1b[0m \\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0;32m      4\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n',\n",
       "   '\\x1b[1;31mTypeError\\x1b[0m: list indices must be integers, not str'],\n",
       "  'user_expressions': {}},\n",
       " [],\n",
       " {'ename': 'TypeError',\n",
       "  'engine_info': {'engine_id': -1,\n",
       "   'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'method': 'execute'},\n",
       "  'evalue': 'list indices must be integers, not str',\n",
       "  'execution_count': 16,\n",
       "  'payload': [],\n",
       "  'status': 'error',\n",
       "  'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "   '\\x1b[1;31mTypeError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "   \"\\x1b[1;32m<ipython-input-16-48b0526ba3da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[1;32m----> 1\\x1b[1;33m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;34m'2'\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\",\n",
       "   '\\x1b[1;32m<ipython-input-14-345e48108d28>\\x1b[0m in \\x1b[0;36mpick\\x1b[1;34m(l, index)\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mdef\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[0ml\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mlist\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[0mindex\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m)\\x1b[0m \\x1b[1;33m->\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m:\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m     \\x1b[1;32mreturn\\x1b[0m \\x1b[0ml\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[0mindex\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\\x1b[0;32m      3\\x1b[0m \\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0;32m      4\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n',\n",
       "   '\\x1b[1;31mTypeError\\x1b[0m: list indices must be integers, not str'],\n",
       "  'user_expressions': {}},\n",
       " ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "  '\\x1b[1;31mTypeError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "  \"\\x1b[1;32m<ipython-input-16-48b0526ba3da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[1;32m----> 1\\x1b[1;33m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;34m'2'\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\",\n",
       "  '\\x1b[1;32m<ipython-input-14-345e48108d28>\\x1b[0m in \\x1b[0;36mpick\\x1b[1;34m(l, index)\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mdef\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[0ml\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mlist\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[0mindex\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m)\\x1b[0m \\x1b[1;33m->\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m:\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m     \\x1b[1;32mreturn\\x1b[0m \\x1b[0ml\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[0mindex\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\\x1b[0;32m      3\\x1b[0m \\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0;32m      4\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n',\n",
       "  '\\x1b[1;31mTypeError\\x1b[0m: list indices must be integers, not str'],\n",
       " {'content': {'ename': 'TypeError',\n",
       "   'engine_info': {'engine_id': -1,\n",
       "    'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "    'method': 'execute'},\n",
       "   'evalue': 'list indices must be integers, not str',\n",
       "   'execution_count': 16,\n",
       "   'payload': [],\n",
       "   'status': 'error',\n",
       "   'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "    '\\x1b[1;31mTypeError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "    \"\\x1b[1;32m<ipython-input-16-48b0526ba3da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[1;32m----> 1\\x1b[1;33m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;34m'2'\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\",\n",
       "    '\\x1b[1;32m<ipython-input-14-345e48108d28>\\x1b[0m in \\x1b[0;36mpick\\x1b[1;34m(l, index)\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mdef\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[0ml\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mlist\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[0mindex\\x1b[0m\\x1b[1;33m:\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m)\\x1b[0m \\x1b[1;33m->\\x1b[0m \\x1b[0mint\\x1b[0m\\x1b[1;33m:\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m     \\x1b[1;32mreturn\\x1b[0m \\x1b[0ml\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[0mindex\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m\\x1b[0;32m      3\\x1b[0m \\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0;32m      4\\x1b[0m \\x1b[0mpick\\x1b[0m\\x1b[1;33m(\\x1b[0m\\x1b[1;33m[\\x1b[0m\\x1b[1;36m1\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m3\\x1b[0m\\x1b[1;33m]\\x1b[0m\\x1b[1;33m,\\x1b[0m \\x1b[1;36m2\\x1b[0m\\x1b[1;33m)\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n',\n",
       "    '\\x1b[1;31mTypeError\\x1b[0m: list indices must be integers, not str'],\n",
       "   'user_expressions': {}},\n",
       "  'header': {'date': datetime.datetime(2016, 3, 20, 1, 44, 44, 397010),\n",
       "   'msg_id': 'af24561a-19fb-429b-a859-0f3c966193e6',\n",
       "   'msg_type': 'execute_reply',\n",
       "   'session': 'bbd10ed7-5a2c-43a4-98b6-3a4760409ca6',\n",
       "   'username': 'pasha',\n",
       "   'version': '5.0'},\n",
       "  'metadata': {'dependencies_met': True,\n",
       "   'engine': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'started': datetime.datetime(2016, 3, 20, 1, 44, 44, 349092),\n",
       "   'status': 'error'},\n",
       "  'msg_id': 'af24561a-19fb-429b-a859-0f3c966193e6',\n",
       "  'msg_type': 'execute_reply',\n",
       "  'parent_header': {'date': '2016-03-20T01:44:44.341120',\n",
       "   'msg_id': '087198E1BE4D48298E906BF6971E9E9A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': 'C7DE1DB7B2DD4D1FA63D6B1AAEF49737',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'tracker': <zmq.sugar.tracker.MessageTracker at 0x7f51c2222b38>},\n",
       " ['import gc\\n'],\n",
       " (10, 1458492336.533345, ['import gc\\n'], '<ipython-input-17-9c3271702575>'),\n",
       " [],\n",
       " <weakref at 0x7f51c00649a8; dead>,\n",
       " <frame at 0x55b8f5438048>,\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 1),\n",
       " <frame at 0x7f51c00bfc48>,\n",
       " <frame at 0x55b8f5455ff8>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059048>,\n",
       " [<zmq.sugar.frame.Frame at 0x7f51c0059048>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059b10>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059bc8>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059c80>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059d38>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059df0>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0059ea8>],\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059b10>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059bc8>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059c80>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059d38>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059df0>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059ea8>,\n",
       " <frame at 0x55b8f546ec88>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059b10>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059bc8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059c80>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059d38>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059df0>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059ea8>],),\n",
       " ((), None),\n",
       " <frame at 0x55b8f5486078>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059b10>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059bc8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059c80>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059d38>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059df0>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0059ea8>],),\n",
       " <frame at 0x7f51c004fda0>,\n",
       " <frame at 0x55b8f5477c18>,\n",
       " [b'4CE6797D9E26478A800FA96DD84CCB50'],\n",
       " {'buffers': [],\n",
       "  'content': {'allow_stdin': True,\n",
       "   'code': 'import gc\\nпс',\n",
       "   'silent': False,\n",
       "   'stop_on_error': True,\n",
       "   'store_history': True,\n",
       "   'user_expressions': {}},\n",
       "  'header': {'date': '2016-03-20T19:45:39.854931',\n",
       "   'msg_id': '1B8734E26BD647268275E6A2781E1807',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'metadata': {},\n",
       "  'msg_id': '1B8734E26BD647268275E6A2781E1807',\n",
       "  'msg_type': 'execute_request',\n",
       "  'parent_header': {}},\n",
       " {'allow_stdin': True,\n",
       "  'code': 'import gc\\nпс',\n",
       "  'silent': False,\n",
       "  'stop_on_error': True,\n",
       "  'store_history': True,\n",
       "  'user_expressions': {}},\n",
       " [],\n",
       " <frame at 0x55b8f5487038>,\n",
       " <frame at 0x55b8f5487938>,\n",
       " <frame at 0x55b8f5487be8>,\n",
       " <cell at 0x7f51c00bd618: ExecutionResult object at 0x7f51c006b518>,\n",
       " <IPython.core.interactiveshell.ExecutionResult at 0x7f51c006b518>,\n",
       " (<cell at 0x7f51c00bd618: ExecutionResult object at 0x7f51c006b518>,),\n",
       " <function IPython.core.interactiveshell.InteractiveShell.run_cell.<locals>.error_before_exec>,\n",
       " ['import gc\\n', 'пс\\n'],\n",
       " (13,\n",
       "  1458492339.8650405,\n",
       "  ['import gc\\n', 'пс\\n'],\n",
       "  '<ipython-input-18-9c73640366da>'),\n",
       " <_ast.Module at 0x7f51c006e748>,\n",
       " [<_ast.Import at 0x7f51c006e7f0>, <_ast.Expr at 0x7f51c006ea90>],\n",
       " <_ast.Import at 0x7f51c006e7f0>,\n",
       " [<_ast.alias at 0x7f51c006e3c8>],\n",
       " <_ast.alias at 0x7f51c006e3c8>,\n",
       " {'col_offset': 0, 'lineno': 1, 'names': [<_ast.alias at 0x7f51c006e3c8>]},\n",
       " <_ast.Expr at 0x7f51c006ea90>,\n",
       " <_ast.Name at 0x7f51c006ebe0>,\n",
       " {'col_offset': 0,\n",
       "  'ctx': <_ast.Load at 0x7f51c972e630>,\n",
       "  'id': 'пс',\n",
       "  'lineno': 2},\n",
       " {'col_offset': 0, 'lineno': 2, 'value': <_ast.Name at 0x7f51c006ebe0>},\n",
       " {'body': [<_ast.Import at 0x7f51c006e7f0>, <_ast.Expr at 0x7f51c006ea90>]},\n",
       " <frame at 0x55b8f545c548>,\n",
       " [<_ast.Import at 0x7f51c006e7f0>],\n",
       " [<_ast.Expr at 0x7f51c006ea90>],\n",
       " [<_ast.Expr at 0x7f51c006ea90>],\n",
       " <_ast.Interactive at 0x7f51c006ecc0>,\n",
       " {'body': [<_ast.Expr at 0x7f51c006ea90>]},\n",
       " ('пс',),\n",
       " (None,),\n",
       " <frame at 0x55b8f546d168>,\n",
       " <frame at 0x55b8f5458da8>,\n",
       " <traceback at 0x7f51c0062048>,\n",
       " <traceback at 0x7f51c0086188>,\n",
       " (\"name 'пс' is not defined\",),\n",
       " NameError(\"name 'пс' is not defined\"),\n",
       " {'error_in_exec': NameError(\"name 'пс' is not defined\"),\n",
       "  'execution_count': 18},\n",
       " <weakref at 0x7f51c00644f8; dead>,\n",
       " [0, 0, 2],\n",
       " ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "  '\\x1b[1;31mNameError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "  '\\x1b[1;32m<ipython-input-18-9c73640366da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mimport\\x1b[0m \\x1b[0mgc\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m \\x1b[0mпс\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m',\n",
       "  \"\\x1b[1;31mNameError\\x1b[0m: name 'пс' is not defined\"],\n",
       " {'ename': 'NameError',\n",
       "  'engine_info': {'engine_id': -1,\n",
       "   'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'method': 'execute'},\n",
       "  'evalue': \"name 'пс' is not defined\",\n",
       "  'execution_count': 18,\n",
       "  'payload': [],\n",
       "  'status': 'error',\n",
       "  'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "   '\\x1b[1;31mNameError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "   '\\x1b[1;32m<ipython-input-18-9c73640366da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mimport\\x1b[0m \\x1b[0mgc\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m \\x1b[0mпс\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m',\n",
       "   \"\\x1b[1;31mNameError\\x1b[0m: name 'пс' is not defined\"],\n",
       "  'user_expressions': {}},\n",
       " [],\n",
       " {'ename': 'NameError',\n",
       "  'engine_info': {'engine_id': -1,\n",
       "   'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'method': 'execute'},\n",
       "  'evalue': \"name 'пс' is not defined\",\n",
       "  'execution_count': 18,\n",
       "  'payload': [],\n",
       "  'status': 'error',\n",
       "  'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "   '\\x1b[1;31mNameError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "   '\\x1b[1;32m<ipython-input-18-9c73640366da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mimport\\x1b[0m \\x1b[0mgc\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m \\x1b[0mпс\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m',\n",
       "   \"\\x1b[1;31mNameError\\x1b[0m: name 'пс' is not defined\"],\n",
       "  'user_expressions': {}},\n",
       " ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "  '\\x1b[1;31mNameError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "  '\\x1b[1;32m<ipython-input-18-9c73640366da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mimport\\x1b[0m \\x1b[0mgc\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m \\x1b[0mпс\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m',\n",
       "  \"\\x1b[1;31mNameError\\x1b[0m: name 'пс' is not defined\"],\n",
       " {'content': {'ename': 'NameError',\n",
       "   'engine_info': {'engine_id': -1,\n",
       "    'engine_uuid': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "    'method': 'execute'},\n",
       "   'evalue': \"name 'пс' is not defined\",\n",
       "   'execution_count': 18,\n",
       "   'payload': [],\n",
       "   'status': 'error',\n",
       "   'traceback': ['\\x1b[1;31m---------------------------------------------------------------------------\\x1b[0m',\n",
       "    '\\x1b[1;31mNameError\\x1b[0m                                 Traceback (most recent call last)',\n",
       "    '\\x1b[1;32m<ipython-input-18-9c73640366da>\\x1b[0m in \\x1b[0;36m<module>\\x1b[1;34m()\\x1b[0m\\n\\x1b[0;32m      1\\x1b[0m \\x1b[1;32mimport\\x1b[0m \\x1b[0mgc\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[1;32m----> 2\\x1b[1;33m \\x1b[0mпс\\x1b[0m\\x1b[1;33m\\x1b[0m\\x1b[0m\\n\\x1b[0m',\n",
       "    \"\\x1b[1;31mNameError\\x1b[0m: name 'пс' is not defined\"],\n",
       "   'user_expressions': {}},\n",
       "  'header': {'date': datetime.datetime(2016, 3, 20, 19, 45, 39, 887091),\n",
       "   'msg_id': '82a931b7-220f-45ed-a36c-b46ed83f1011',\n",
       "   'msg_type': 'execute_reply',\n",
       "   'session': 'bbd10ed7-5a2c-43a4-98b6-3a4760409ca6',\n",
       "   'username': 'pasha',\n",
       "   'version': '5.0'},\n",
       "  'metadata': {'dependencies_met': True,\n",
       "   'engine': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'started': datetime.datetime(2016, 3, 20, 19, 45, 39, 855338),\n",
       "   'status': 'error'},\n",
       "  'msg_id': '82a931b7-220f-45ed-a36c-b46ed83f1011',\n",
       "  'msg_type': 'execute_reply',\n",
       "  'parent_header': {'date': '2016-03-20T19:45:39.854931',\n",
       "   'msg_id': '1B8734E26BD647268275E6A2781E1807',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'tracker': <zmq.sugar.tracker.MessageTracker at 0x7f51c2222b38>},\n",
       " ['import gc\\n', 'gc\\n'],\n",
       " (13,\n",
       "  1458492343.0486176,\n",
       "  ['import gc\\n', 'gc\\n'],\n",
       "  '<ipython-input-19-6ceba25ff0d6>'),\n",
       " <weakref at 0x7f51c0064638; dead>,\n",
       " {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       " ['import gc\\n', 'gc.garbage\\n'],\n",
       " (21,\n",
       "  1458492346.42364,\n",
       "  ['import gc\\n', 'gc.garbage\\n'],\n",
       "  '<ipython-input-20-f74d4ae451db>'),\n",
       " <weakref at 0x7f51c0064b38; dead>,\n",
       " [],\n",
       " <_io.StringIO at 0x7f51c00a43a8>,\n",
       " [],\n",
       " <_io.StringIO at 0x7f51c00a4ca8>,\n",
       " [],\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 5),\n",
       " [],\n",
       " [functools.partial(<function wrap.<locals>.null_wrapper at 0x7f51c00b5ea0>)],\n",
       " [(21, 'gc.get_objects()', 'gc.get_objects()')],\n",
       " [],\n",
       " <frame at 0x55b8f545cbe8>,\n",
       " <frame at 0x55b8f5454be8>,\n",
       " <function lock.acquire>,\n",
       " (1.0,),\n",
       " [(<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 1)],\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 1),\n",
       " <frame at 0x55b8f546ea48>,\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 1),\n",
       " (<zmq.eventloop.zmqstream.ZMQStream at 0x7f51c12216d8>,\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11eaca8>,\n",
       "  1),\n",
       " <frame at 0x55b8f545b988>,\n",
       " <frame at 0x55b8f5470fb8>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       " [<zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       "  <zmq.sugar.frame.Frame at 0x7f51c00843e0>],\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       " <zmq.sugar.frame.Frame at 0x7f51c00843e0>,\n",
       " <frame at 0x55b8f5459738>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00843e0>],),\n",
       " <tornado.stack_context.NullContext at 0x7f51c006e1d0>,\n",
       " <bound method NullContext.__exit__ of <tornado.stack_context.NullContext object at 0x7f51c006e1d0>>,\n",
       " ((), None),\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00843e0>],),\n",
       " <frame at 0x55b8f54373e8>,\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00843e0>],),\n",
       " ([<zmq.sugar.frame.Frame at 0x7f51c0059f60>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084048>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084100>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00841b8>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084270>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c0084328>,\n",
       "   <zmq.sugar.frame.Frame at 0x7f51c00843e0>],),\n",
       " <frame at 0x55b8f545d508>,\n",
       " <frame at 0x55b8f545b0e8>,\n",
       " [b'4CE6797D9E26478A800FA96DD84CCB50'],\n",
       " {'buffers': [],\n",
       "  'content': {'allow_stdin': True,\n",
       "   'code': 'gc.get_objects()',\n",
       "   'silent': False,\n",
       "   'stop_on_error': True,\n",
       "   'store_history': True,\n",
       "   'user_expressions': {}},\n",
       "  'header': {'date': '2016-03-20T19:46:05.318327',\n",
       "   'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'metadata': {},\n",
       "  'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "  'msg_type': 'execute_request',\n",
       "  'parent_header': {}},\n",
       " {'allow_stdin': True,\n",
       "  'code': 'gc.get_objects()',\n",
       "  'silent': False,\n",
       "  'stop_on_error': True,\n",
       "  'store_history': True,\n",
       "  'user_expressions': {}},\n",
       " [],\n",
       " [b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.status',\n",
       "  b'<IDS|MSG>',\n",
       "  b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4',\n",
       "  b'{\"version\":\"5.0\",\"msg_id\":\"5eed5d40-b2ce-4322-97a5-7e640fb8f489\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"status\",\"date\":\"2016-03-20T19:46:05.318538\"}',\n",
       "  b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "  b'{}',\n",
       "  b'{\"execution_state\":\"busy\"}'],\n",
       " ([b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.status',\n",
       "   b'<IDS|MSG>',\n",
       "   b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4',\n",
       "   b'{\"version\":\"5.0\",\"msg_id\":\"5eed5d40-b2ce-4322-97a5-7e640fb8f489\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"status\",\"date\":\"2016-03-20T19:46:05.318538\"}',\n",
       "   b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "   b'{}',\n",
       "   b'{\"execution_state\":\"busy\"}'],),\n",
       " <cell at 0x7f51c00bd378: tuple object at 0x7f51c00a5eb8>,\n",
       " <cell at 0x7f51c00bd318: dict object at 0x7f51c0079f88>,\n",
       " <cell at 0x7f51c00bd468: IOPubThread object at 0x7f51c124be48>,\n",
       " (<cell at 0x7f51c00bd378: tuple object at 0x7f51c00a5eb8>,\n",
       "  <cell at 0x7f51c00bd318: dict object at 0x7f51c0079f88>,\n",
       "  <cell at 0x7f51c00bd468: IOPubThread object at 0x7f51c124be48>),\n",
       " <function ipykernel.iostream.IOPubThread.send_multipart.<locals>.<lambda>>,\n",
       " <cell at 0x7f51c00bd8e8: list object at 0x7f51c00862c8>,\n",
       " <cell at 0x7f51c00bd8b8: function object at 0x7f51c00b5598>,\n",
       " [((), None)],\n",
       " (<cell at 0x7f51c00bd8e8: list object at 0x7f51c00862c8>,\n",
       "  <cell at 0x7f51c00bd8b8: function object at 0x7f51c00b5598>),\n",
       " <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       " functools.partial(<function wrap.<locals>.null_wrapper at 0x7f51c00b5ea0>),\n",
       " <frame at 0x55b8f5489a58>,\n",
       " [(18, 1)],\n",
       " (18, 1),\n",
       " [functools.partial(<function wrap.<locals>.null_wrapper at 0x7f51c00b5f28>)],\n",
       " [],\n",
       " <list_iterator at 0x7f51c006b160>,\n",
       " <frame at 0x7f51b4001f48>,\n",
       " <frame at 0x55b8f54549a8>,\n",
       " <frame at 0x7f51c00ceaf8>,\n",
       " (<ipykernel.iostream.IOPubThread at 0x7f51c124be48>,\n",
       "  [b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.status',\n",
       "   b'<IDS|MSG>',\n",
       "   b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4',\n",
       "   b'{\"version\":\"5.0\",\"msg_id\":\"5eed5d40-b2ce-4322-97a5-7e640fb8f489\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"status\",\"date\":\"2016-03-20T19:46:05.318538\"}',\n",
       "   b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "   b'{}',\n",
       "   b'{\"execution_state\":\"busy\"}']),\n",
       " ('copy', True),\n",
       " <frame at 0x7f51c00d5238>,\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eadc8>,\n",
       "  [b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.status',\n",
       "   b'<IDS|MSG>',\n",
       "   b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4',\n",
       "   b'{\"version\":\"5.0\",\"msg_id\":\"5eed5d40-b2ce-4322-97a5-7e640fb8f489\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"status\",\"date\":\"2016-03-20T19:46:05.318538\"}',\n",
       "   b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "   b'{}',\n",
       "   b'{\"execution_state\":\"busy\"}']),\n",
       " ('copy', True),\n",
       " <frame at 0x55b8f54875d8>,\n",
       " [b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.status',\n",
       "  b'<IDS|MSG>',\n",
       "  b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4',\n",
       "  b'{\"version\":\"5.0\",\"msg_id\":\"5eed5d40-b2ce-4322-97a5-7e640fb8f489\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"status\",\"date\":\"2016-03-20T19:46:05.318538\"}',\n",
       "  b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "  b'{}'],\n",
       " <list_iterator at 0x7f51c006eef0>,\n",
       " <function Socket.send>,\n",
       " (b'ecb412c063171fde8c8f2fac7430fe7a46d403f5ba39f666f11aae27874b1ae4', 2),\n",
       " [b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.execute_input',\n",
       "  b'<IDS|MSG>',\n",
       "  b'bab7db0cbbf705a3806db6eb7783adbff55ac0f37e237047e122362a253e4331',\n",
       "  b'{\"version\":\"5.0\",\"msg_id\":\"3ad7161c-ae6c-43d0-bfc4-d8bdc7ca7d81\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"execute_input\",\"date\":\"2016-03-20T19:46:05.318956\"}',\n",
       "  b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "  b'{}',\n",
       "  b'{\"execution_count\":21,\"code\":\"gc.get_objects()\"}'],\n",
       " ([b'kernel.60debbe5-9e37-44be-8878-88c400d6728c.execute_input',\n",
       "   b'<IDS|MSG>',\n",
       "   b'bab7db0cbbf705a3806db6eb7783adbff55ac0f37e237047e122362a253e4331',\n",
       "   b'{\"version\":\"5.0\",\"msg_id\":\"3ad7161c-ae6c-43d0-bfc4-d8bdc7ca7d81\",\"session\":\"bbd10ed7-5a2c-43a4-98b6-3a4760409ca6\",\"username\":\"pasha\",\"msg_type\":\"execute_input\",\"date\":\"2016-03-20T19:46:05.318956\"}',\n",
       "   b'{\"session\":\"4CE6797D9E26478A800FA96DD84CCB50\",\"msg_type\":\"execute_request\",\"version\":\"5.0\",\"username\":\"username\",\"msg_id\":\"BF3CEE6EC01944EEA25FA7825F7AD98A\",\"date\":\"2016-03-20T19:46:05.318327\"}',\n",
       "   b'{}',\n",
       "   b'{\"execution_count\":21,\"code\":\"gc.get_objects()\"}'],),\n",
       " <cell at 0x7f51c00bd198: tuple object at 0x7f51c006e8d0>,\n",
       " <cell at 0x7f51c00bd438: dict object at 0x7f51c0086308>,\n",
       " <cell at 0x7f51c00bd288: IOPubThread object at 0x7f51c124be48>,\n",
       " (<cell at 0x7f51c00bd198: tuple object at 0x7f51c006e8d0>,\n",
       "  <cell at 0x7f51c00bd438: dict object at 0x7f51c0086308>,\n",
       "  <cell at 0x7f51c00bd288: IOPubThread object at 0x7f51c124be48>),\n",
       " <function ipykernel.iostream.IOPubThread.send_multipart.<locals>.<lambda>>,\n",
       " <cell at 0x7f51c00bd108: list object at 0x7f51c0086fc8>,\n",
       " <cell at 0x7f51c00bd0a8: function object at 0x7f51c00b57b8>,\n",
       " [((), None)],\n",
       " (<cell at 0x7f51c00bd108: list object at 0x7f51c0086fc8>,\n",
       "  <cell at 0x7f51c00bd0a8: function object at 0x7f51c00b57b8>),\n",
       " <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       " functools.partial(<function wrap.<locals>.null_wrapper at 0x7f51c00b5f28>),\n",
       " <frame at 0x55b8f548a358>,\n",
       " <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.getpass of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <frame at 0x55b8f548a608>,\n",
       " <cell at 0x7f51c00bd3a8: ExecutionResult object at 0x7f51c006e400>,\n",
       " <IPython.core.interactiveshell.ExecutionResult at 0x7f51c006e400>,\n",
       " (<cell at 0x7f51c00bd3a8: ExecutionResult object at 0x7f51c006e400>,),\n",
       " <function IPython.core.interactiveshell.InteractiveShell.run_cell.<locals>.error_before_exec>,\n",
       " ['gc.get_objects()'],\n",
       " <bound method assemble_python_lines.get_line of <IPython.core.inputtransformer.assemble_python_lines object at 0x7f51c00a5438>>,\n",
       " <frame at 0x55b8f54446f8>,\n",
       " <generator object _tokenize at 0x7f51c00bccf0>,\n",
       " (21, 'gc.get_objects()', 'gc.get_objects()'),\n",
       " <bound method BuiltinTrap.__exit__ of <IPython.core.builtin_trap.BuiltinTrap object at 0x7f51c016eef0>>,\n",
       " ['gc.get_objects()\\n'],\n",
       " (17,\n",
       "  1458492365.3196926,\n",
       "  ['gc.get_objects()\\n'],\n",
       "  '<ipython-input-21-270fbd95f7f5>'),\n",
       " <bound method DisplayTrap.__exit__ of <IPython.core.display_trap.DisplayTrap object at 0x7f51c0113320>>,\n",
       " <_ast.Module at 0x7f51c006ee80>,\n",
       " [<_ast.Expr at 0x7f51c006ec88>],\n",
       " <_ast.Expr at 0x7f51c006ec88>,\n",
       " <_ast.Call at 0x7f51c006e7b8>,\n",
       " <_ast.Attribute at 0x7f51c006ed30>,\n",
       " <_ast.Name at 0x7f51c006efd0>,\n",
       " {'col_offset': 0,\n",
       "  'ctx': <_ast.Load at 0x7f51c972e630>,\n",
       "  'id': 'gc',\n",
       "  'lineno': 1},\n",
       " {'attr': 'get_objects',\n",
       "  'col_offset': 0,\n",
       "  'ctx': <_ast.Load at 0x7f51c972e630>,\n",
       "  'lineno': 1,\n",
       "  'value': <_ast.Name at 0x7f51c006efd0>},\n",
       " {'args': [],\n",
       "  'col_offset': 0,\n",
       "  'func': <_ast.Attribute at 0x7f51c006ed30>,\n",
       "  'keywords': [],\n",
       "  'kwargs': None,\n",
       "  'lineno': 1,\n",
       "  'starargs': None},\n",
       " [],\n",
       " [],\n",
       " {'col_offset': 0, 'lineno': 1, 'value': <_ast.Call at 0x7f51c006e7b8>},\n",
       " {'body': [<_ast.Expr at 0x7f51c006ec88>]},\n",
       " <frame at 0x55b8f546c078>,\n",
       " [],\n",
       " [<_ast.Expr at 0x7f51c006ec88>],\n",
       " <enumerate at 0x7f51c00d0828>,\n",
       " <list_iterator at 0x7f51c006e2b0>,\n",
       " (0, <_ast.Expr at 0x7f51c006ec88>),\n",
       " [<_ast.Expr at 0x7f51c006ec88>],\n",
       " <_ast.Interactive at 0x7f51c006eda0>,\n",
       " {'body': [<_ast.Expr at 0x7f51c006ec88>]},\n",
       " ('gc', 'get_objects'),\n",
       " (None,),\n",
       " <frame at 0x55b8f5489ed8>,\n",
       " <bound method ZMQInteractiveShell.excepthook of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       " (<code object <module> at 0x7f51c00a4810, file \"<ipython-input-21-270fbd95f7f5>\", line 1>,\n",
       "  {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}},\n",
       "  {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}}),\n",
       " <frame at 0x7f51c004e228>,\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eae28>, 5),\n",
       " <Thread(Thread-2, started daemon 139989023192832)>,\n",
       " {'_args': (),\n",
       "  '_daemonic': True,\n",
       "  '_ident': 139989023192832,\n",
       "  '_initialized': True,\n",
       "  '_is_stopped': False,\n",
       "  '_kwargs': {},\n",
       "  '_name': 'Thread-2',\n",
       "  '_started': <threading.Event at 0x7f51c12212e8>,\n",
       "  '_stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>,\n",
       "  '_target': <bound method IOPubThread._thread_main of <ipykernel.iostream.IOPubThread object at 0x7f51c124be48>>,\n",
       "  '_tstate_lock': <_thread.lock at 0x7f51c12893f0>},\n",
       " <threading.Event at 0x7f51c12212e8>,\n",
       " {'_cond': <Condition(<_thread.lock object at 0x7f51c125c3a0>, 0)>,\n",
       "  '_flag': True},\n",
       " <weakref at 0x7f51c11d5548; to 'Thread' at 0x7f51c1221fd0>,\n",
       " {},\n",
       " <bound method Thread._bootstrap of <Thread(Thread-2, started daemon 139989023192832)>>,\n",
       " (<Thread(Thread-2, started daemon 139989023192832)>,),\n",
       " <frame at 0x7f51c11dc418>,\n",
       " <frame at 0x7f51b40008d8>,\n",
       " <weakref at 0x7f51caad94f8; to '_thread.lock' at 0x7f51c12893f0>,\n",
       " <frame at 0x7f51c11f6428>,\n",
       " (<ipykernel.iostream.IOPubThread at 0x7f51c124be48>,),\n",
       " <frame at 0x7f51c11dbd88>,\n",
       " <frame at 0x7f51b4000e68>,\n",
       " <frame at 0x7f51b40010a8>,\n",
       " <logging.Logger at 0x7f51c1221ef0>,\n",
       " {'disabled': False,\n",
       "  'filters': [],\n",
       "  'handlers': [],\n",
       "  'level': 0,\n",
       "  'manager': <logging.Manager at 0x7f51c9fd5cf8>,\n",
       "  'name': 'tornado',\n",
       "  'parent': <logging.RootLogger at 0x7f51c9fd5be0>,\n",
       "  'propagate': True},\n",
       " [],\n",
       " <logging.StreamHandler at 0x7f51c1fe6400>,\n",
       " {'_name': None,\n",
       "  'filters': [],\n",
       "  'formatter': <logging.Formatter at 0x7f51c1221e10>,\n",
       "  'level': 0,\n",
       "  'lock': <_thread.RLock owner=0 count=0>,\n",
       "  'stream': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>},\n",
       " <weakref at 0x7f51c1241688; to 'StreamHandler' at 0x7f51c1fe6400>,\n",
       " <logging.Formatter at 0x7f51c1221e10>,\n",
       " {'_fmt': '%(levelname)s:%(name)s:%(message)s',\n",
       "  '_style': <logging.PercentStyle at 0x7f51c1221d68>,\n",
       "  'datefmt': None},\n",
       " <weakref at 0x7f51c1241638; to '_thread._localdummy' at 0x7f51c124e5f0>,\n",
       " {'instance': <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c124bcf8>},\n",
       " <bound method IOPubThread.stop of <ipykernel.iostream.IOPubThread object at 0x7f51c124be48>>,\n",
       " <function zmq.sugar.context.Context.__init__.<locals>._notify_atexit>,\n",
       " <Heartbeat(Thread-3, started daemon 139989014800128)>,\n",
       " {'_args': (),\n",
       "  '_daemonic': True,\n",
       "  '_ident': 139989014800128,\n",
       "  '_initialized': True,\n",
       "  '_is_stopped': False,\n",
       "  '_kwargs': {},\n",
       "  '_name': 'Thread-3',\n",
       "  '_started': <threading.Event at 0x7f51c1221c18>,\n",
       "  '_stderr': <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>,\n",
       "  '_target': None,\n",
       "  '_tstate_lock': <_thread.lock at 0x7f51c12895a8>,\n",
       "  'addr': ('127.0.0.1', 39269),\n",
       "  'context': <zmq.sugar.context.Context at 0x7f51c11ee2e8>,\n",
       "  'ip': '127.0.0.1',\n",
       "  'port': 39269,\n",
       "  'socket': <zmq.sugar.socket.Socket at 0x7f51c11eae88>,\n",
       "  'transport': 'tcp'},\n",
       " <threading.Event at 0x7f51c1221c18>,\n",
       " {'_cond': <Condition(<_thread.lock object at 0x7f51c1289490>, 0)>,\n",
       "  '_flag': True},\n",
       " <weakref at 0x7f51c1241778; to 'Heartbeat' at 0x7f51c1221d30>,\n",
       " <bound method Heartbeat._bootstrap of <Heartbeat(Thread-3, started daemon 139989014800128)>>,\n",
       " (<Heartbeat(Thread-3, started daemon 139989014800128)>,),\n",
       " <frame at 0x7f51c11dc7e8>,\n",
       " <frame at 0x7f51ac0008d8>,\n",
       " <weakref at 0x7f51c12417c8; to '_thread.lock' at 0x7f51c12895a8>,\n",
       " <frame at 0x7f51ac000e68>,\n",
       " <zmq.sugar.socket.Socket at 0x7f51c11eae88>,\n",
       " (3,\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11eae88>,\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11eae88>),\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eae88>,\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11eae88>),\n",
       " <ipykernel.iostream.OutStream at 0x7f51c1221b70>,\n",
       " {'_buffer': <_io.StringIO at 0x7f51c00a43a8>,\n",
       "  '_flush_lock': <_thread.lock at 0x7f51c12894e0>,\n",
       "  '_flush_timeout': None,\n",
       "  '_io_loop': <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c124bcf8>,\n",
       "  '_master_pid': 22826,\n",
       "  'encoding': 'UTF-8',\n",
       "  'name': 'stdout',\n",
       "  'parent_header': {'date': '2016-03-20T19:46:05.318327',\n",
       "   'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'pub_thread': <ipykernel.iostream.IOPubThread at 0x7f51c124be48>,\n",
       "  'session': <jupyter_client.session.Session at 0x7f51c124be10>,\n",
       "  'softspace': 0,\n",
       "  'topic': b'stream.stdout'},\n",
       " <ipykernel.iostream.OutStream at 0x7f51c1221b38>,\n",
       " {'_buffer': <_io.StringIO at 0x7f51c00a4ca8>,\n",
       "  '_flush_lock': <_thread.lock at 0x7f51c1289508>,\n",
       "  '_flush_timeout': None,\n",
       "  '_io_loop': <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c124bcf8>,\n",
       "  '_master_pid': 22826,\n",
       "  'encoding': 'UTF-8',\n",
       "  'name': 'stderr',\n",
       "  'parent_header': {'date': '2016-03-20T19:46:05.318327',\n",
       "   'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "   'username': 'username',\n",
       "   'version': '5.0'},\n",
       "  'pub_thread': <ipykernel.iostream.IOPubThread at 0x7f51c124be48>,\n",
       "  'session': <jupyter_client.session.Session at 0x7f51c124be10>,\n",
       "  'topic': b'stream.stderr'},\n",
       " <ipykernel.displayhook.ZMQDisplayHook at 0x7f51c12217b8>,\n",
       " {'parent_header': {},\n",
       "  'pub_socket': <ipykernel.iostream.BackgroundSocket at 0x7f51c124bdd8>,\n",
       "  'session': <jupyter_client.session.Session at 0x7f51c124be10>},\n",
       " <module 'faulthandler' (built-in)>,\n",
       " {'__doc__': 'faulthandler module.',\n",
       "  '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "  '__name__': 'faulthandler',\n",
       "  '__package__': '',\n",
       "  '__spec__': ModuleSpec(name='faulthandler', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'),\n",
       "  '_fatal_error': <function faulthandler._fatal_error>,\n",
       "  '_read_null': <function faulthandler._read_null>,\n",
       "  '_sigabrt': <function faulthandler._sigabrt>,\n",
       "  '_sigbus': <function faulthandler._sigbus>,\n",
       "  '_sigfpe': <function faulthandler._sigfpe>,\n",
       "  '_sigill': <function faulthandler._sigill>,\n",
       "  '_sigsegv': <function faulthandler._sigsegv>,\n",
       "  '_stack_overflow': <function faulthandler._stack_overflow>,\n",
       "  'cancel_dump_traceback_later': <function faulthandler.cancel_dump_traceback_later>,\n",
       "  'disable': <function faulthandler.disable>,\n",
       "  'dump_traceback': <function faulthandler.dump_traceback>,\n",
       "  'dump_traceback_later': <function faulthandler.dump_traceback_later>,\n",
       "  'enable': <function ipykernel.kernelapp.IPKernelApp.patch_io.<locals>.enable>,\n",
       "  'is_enabled': <function faulthandler.is_enabled>,\n",
       "  'register': <function ipykernel.kernelapp.IPKernelApp.patch_io.<locals>.register>,\n",
       "  'unregister': <function faulthandler.unregister>},\n",
       " <function faulthandler.disable>,\n",
       " <function faulthandler.is_enabled>,\n",
       " <function faulthandler.dump_traceback>,\n",
       " <function faulthandler.dump_traceback_later>,\n",
       " <function faulthandler.cancel_dump_traceback_later>,\n",
       " <function faulthandler.unregister>,\n",
       " <function faulthandler._read_null>,\n",
       " <function faulthandler._sigsegv>,\n",
       " <function faulthandler._sigabrt>,\n",
       " <function faulthandler._sigfpe>,\n",
       " <function faulthandler._sigbus>,\n",
       " <function faulthandler._sigill>,\n",
       " <function faulthandler._fatal_error>,\n",
       " <function faulthandler._stack_overflow>,\n",
       " <function ipykernel.kernelapp.IPKernelApp.patch_io.<locals>.enable>,\n",
       " (<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>, True),\n",
       " <function ipykernel.kernelapp.IPKernelApp.patch_io.<locals>.register>,\n",
       " (<_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>, True, False),\n",
       " <zmq.eventloop.zmqstream.ZMQStream at 0x7f51c12216d8>,\n",
       " {'_close_callback': None,\n",
       "  '_flushed': False,\n",
       "  '_recv_callback': <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       "  '_recv_copy': False,\n",
       "  '_send_callback': <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       "  '_send_queue': <queue.Queue at 0x7f51c1221390>,\n",
       "  '_state': 25,\n",
       "  'bind': <function Socket.bind>,\n",
       "  'bind_to_random_port': <bound method Socket.bind_to_random_port of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       "  'connect': <function Socket.connect>,\n",
       "  'getsockopt': <function Socket.get>,\n",
       "  'getsockopt_string': <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       "  'getsockopt_unicode': <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       "  'io_loop': <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c12214a8>,\n",
       "  'poller': <zmq.sugar.poll.Poller at 0x7f51c1221320>,\n",
       "  'setsockopt': <function Socket.set>,\n",
       "  'setsockopt_string': <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       "  'setsockopt_unicode': <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       "  'socket': <zmq.sugar.socket.Socket at 0x7f51c11eaca8>},\n",
       " <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c12214a8>,\n",
       " {'_blocking_signal_threshold': None,\n",
       "  '_callback_lock': <_thread.lock at 0x7f51c1289558>,\n",
       "  '_callbacks': [],\n",
       "  '_cancellations': 0,\n",
       "  '_closing': False,\n",
       "  '_events': {},\n",
       "  '_handlers': {<zmq.sugar.socket.Socket at 0x7f51c11eaca8>: (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>,\n",
       "    <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       "   29: (29, <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       "   <zmq.sugar.socket.Socket at 0x7f51c11ead68>: (<zmq.sugar.socket.Socket at 0x7f51c11ead68>,\n",
       "    <function tornado.stack_context.wrap.<locals>.null_wrapper>)},\n",
       "  '_impl': <zmq.eventloop.ioloop.ZMQPoller at 0x7f51c1221438>,\n",
       "  '_running': True,\n",
       "  '_stopped': False,\n",
       "  '_thread_ident': 139989404575488,\n",
       "  '_timeout_counter': count(0),\n",
       "  '_timeouts': [],\n",
       "  '_waker': <tornado.platform.posix.Waker at 0x7f51c1221ba8>,\n",
       "  'time_func': <function time.time>},\n",
       " [],\n",
       " count(0),\n",
       " <tornado.platform.posix.Waker at 0x7f51c1221ba8>,\n",
       " {'reader': <_io.FileIO name=29 mode='rb'>,\n",
       "  'writer': <_io.FileIO name=30 mode='wb'>},\n",
       " <_io.FileIO name=30 mode='wb'>,\n",
       " {<zmq.sugar.socket.Socket at 0x7f51c11eaca8>: (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>,\n",
       "   <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       "  29: (29, <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11ead68>: (<zmq.sugar.socket.Socket at 0x7f51c11ead68>,\n",
       "   <function tornado.stack_context.wrap.<locals>.null_wrapper>)},\n",
       " <zmq.sugar.poll.Poller at 0x7f51c1221320>,\n",
       " {'_map': {}, 'sockets': []},\n",
       " <queue.Queue at 0x7f51c1221390>,\n",
       " {'all_tasks_done': <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       "  'maxsize': 0,\n",
       "  'mutex': <_thread.lock at 0x7f51c12895d0>,\n",
       "  'not_empty': <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       "  'not_full': <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       "  'queue': deque([]),\n",
       "  'unfinished_tasks': 25},\n",
       " <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c12895d0>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c12895d0>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " <Condition(<_thread.lock object at 0x7f51c12895d0>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c12895d0>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>,\n",
       "  <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       " <function Socket.bind>,\n",
       " <bound method Socket.bind_to_random_port of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       " <function Socket.connect>,\n",
       " <function Socket.set>,\n",
       " <function Socket.get>,\n",
       " <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       " <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       " <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       " <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11eaca8>>,\n",
       " <zmq.eventloop.zmqstream.ZMQStream at 0x7f51c1221358>,\n",
       " {'_close_callback': None,\n",
       "  '_flushed': False,\n",
       "  '_recv_callback': <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       "  '_recv_copy': False,\n",
       "  '_send_callback': None,\n",
       "  '_send_queue': <queue.Queue at 0x7f51c1221160>,\n",
       "  '_state': 25,\n",
       "  'bind': <function Socket.bind>,\n",
       "  'bind_to_random_port': <bound method Socket.bind_to_random_port of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       "  'connect': <function Socket.connect>,\n",
       "  'getsockopt': <function Socket.get>,\n",
       "  'getsockopt_string': <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       "  'getsockopt_unicode': <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       "  'io_loop': <zmq.eventloop.ioloop.ZMQIOLoop at 0x7f51c12214a8>,\n",
       "  'poller': <zmq.sugar.poll.Poller at 0x7f51c1221198>,\n",
       "  'setsockopt': <function Socket.set>,\n",
       "  'setsockopt_string': <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       "  'setsockopt_unicode': <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       "  'socket': <zmq.sugar.socket.Socket at 0x7f51c11ead68>},\n",
       " <zmq.sugar.poll.Poller at 0x7f51c1221198>,\n",
       " {'_map': {}, 'sockets': []},\n",
       " <queue.Queue at 0x7f51c1221160>,\n",
       " {'all_tasks_done': <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       "  'maxsize': 0,\n",
       "  'mutex': <_thread.lock at 0x7f51c1289648>,\n",
       "  'not_empty': <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       "  'not_full': <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       "  'queue': deque([]),\n",
       "  'unfinished_tasks': 0},\n",
       " <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c1289648>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c1289648>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " <Condition(<_thread.lock object at 0x7f51c1289648>, 0)>,\n",
       " {'_lock': <_thread.lock at 0x7f51c1289648>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <function lock.release>,\n",
       " deque([]),\n",
       " (<zmq.sugar.socket.Socket at 0x7f51c11ead68>,\n",
       "  <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       " <function Socket.bind>,\n",
       " <bound method Socket.bind_to_random_port of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       " <function Socket.connect>,\n",
       " <function Socket.set>,\n",
       " <function Socket.get>,\n",
       " <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       " <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       " <bound method Socket.set_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       " <bound method Socket.get_string of <zmq.sugar.socket.Socket object at 0x7f51c11ead68>>,\n",
       " [<zmq.eventloop.zmqstream.ZMQStream at 0x7f51c12216d8>,\n",
       "  <zmq.eventloop.zmqstream.ZMQStream at 0x7f51c1221358>],\n",
       " <ipykernel.ipkernel.IPythonKernel at 0x7f51c1221278>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_save_getpass': <function getpass.unix_getpass>,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'_allow_stdin': True,\n",
       "   '_darwin_app_nap': True,\n",
       "   '_execute_sleep': 0.0005,\n",
       "   '_parent_header': {'buffers': [],\n",
       "    'content': {'allow_stdin': True,\n",
       "     'code': 'gc.get_objects()',\n",
       "     'silent': False,\n",
       "     'stop_on_error': True,\n",
       "     'store_history': True,\n",
       "     'user_expressions': {}},\n",
       "    'header': {'date': '2016-03-20T19:46:05.318327',\n",
       "     'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "     'msg_type': 'execute_request',\n",
       "     'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "     'username': 'username',\n",
       "     'version': '5.0'},\n",
       "    'metadata': {},\n",
       "    'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "    'msg_type': 'execute_request',\n",
       "    'parent_header': {}},\n",
       "   '_parent_ident': [b'4CE6797D9E26478A800FA96DD84CCB50'],\n",
       "   '_poll_interval': 0.05,\n",
       "   '_recorded_ports': {'control': 42492,\n",
       "    'hb': 39269,\n",
       "    'iopub': 54629,\n",
       "    'shell': 39890,\n",
       "    'stdin': 58359},\n",
       "   '_sys_eval_input': None,\n",
       "   '_sys_raw_input': <function input>,\n",
       "   'aborted': set(),\n",
       "   'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'control_stream': None,\n",
       "   'eventloop': None,\n",
       "   'help_links': [{'text': 'Python', 'url': 'http://docs.python.org/3.4'},\n",
       "    {'text': 'IPython', 'url': 'http://ipython.org/documentation.html'},\n",
       "    {'text': 'NumPy', 'url': 'http://docs.scipy.org/doc/numpy/reference/'},\n",
       "    {'text': 'SciPy', 'url': 'http://docs.scipy.org/doc/scipy/reference/'},\n",
       "    {'text': 'Matplotlib', 'url': 'http://matplotlib.org/contents.html'},\n",
       "    {'text': 'SymPy', 'url': 'http://docs.sympy.org/latest/index.html'},\n",
       "    {'text': 'pandas', 'url': 'http://pandas.pydata.org/pandas-docs/stable/'}],\n",
       "   'ident': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "   'int_id': -1,\n",
       "   'iopub_socket': <ipykernel.iostream.BackgroundSocket at 0x7f51c124bdd8>,\n",
       "   'iopub_thread': <ipykernel.iostream.IOPubThread at 0x7f51c124be48>,\n",
       "   'log': <logging.Logger at 0x7f51d2a1aba8>,\n",
       "   'parent': <ipykernel.kernelapp.IPKernelApp at 0x7f51d2a1ac18>,\n",
       "   'profile_dir': <IPython.core.profiledir.ProfileDir at 0x7f51c1221518>,\n",
       "   'session': <jupyter_client.session.Session at 0x7f51c124be10>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "   'shell_class': ipykernel.zmqshell.ZMQInteractiveShell,\n",
       "   'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream at 0x7f51c12216d8>,\n",
       "    <zmq.eventloop.zmqstream.ZMQStream at 0x7f51c1221358>],\n",
       "   'stdin_socket': <zmq.sugar.socket.Socket at 0x7f51c11ead08>,\n",
       "   'user_module': None,\n",
       "   'user_ns': None},\n",
       "  'comm_manager': <ipykernel.comm.manager.CommManager at 0x7f51c0147940>,\n",
       "  'control_handlers': {'abort_request': <bound method IPythonKernel.abort_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'apply_request': <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'clear_request': <bound method IPythonKernel.clear_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'comm_info_request': <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'complete_request': <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'connect_request': <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'execute_request': <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'history_request': <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'inspect_request': <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'is_complete_request': <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'kernel_info_request': <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'shutdown_request': <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>},\n",
       "  'saved_sigint_handler': 1,\n",
       "  'shell_handlers': {'apply_request': <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'comm_close': <bound method CommManager.comm_close of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "   'comm_info_request': <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'comm_msg': <bound method CommManager.comm_msg of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "   'comm_open': <bound method CommManager.comm_open of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "   'complete_request': <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'connect_request': <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'execute_request': <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'history_request': <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'inspect_request': <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'is_complete_request': <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'kernel_info_request': <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'shutdown_request': <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " (27075,\n",
       "  1457880526.352978,\n",
       "  ['\"\"\"Base class for a kernel that talks to frontends over 0MQ.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '# Copyright (c) IPython Development Team.\\n',\n",
       "   '# Distributed under the terms of the Modified BSD License.\\n',\n",
       "   '\\n',\n",
       "   'from __future__ import print_function\\n',\n",
       "   '\\n',\n",
       "   'import sys\\n',\n",
       "   'import time\\n',\n",
       "   'import logging\\n',\n",
       "   'import uuid\\n',\n",
       "   '\\n',\n",
       "   'from datetime import datetime\\n',\n",
       "   'from signal import (\\n',\n",
       "   '        signal, default_int_handler, SIGINT\\n',\n",
       "   ')\\n',\n",
       "   '\\n',\n",
       "   'import zmq\\n',\n",
       "   'from zmq.eventloop import ioloop\\n',\n",
       "   'from zmq.eventloop.zmqstream import ZMQStream\\n',\n",
       "   '\\n',\n",
       "   'from traitlets.config.configurable import SingletonConfigurable\\n',\n",
       "   'from IPython.core.error import StdinNotImplementedError\\n',\n",
       "   'from ipython_genutils import py3compat\\n',\n",
       "   'from ipython_genutils.py3compat import unicode_type, string_types\\n',\n",
       "   'from ipykernel.jsonutil import json_clean\\n',\n",
       "   'from traitlets import (\\n',\n",
       "   '    Any, Instance, Float, Dict, List, Set, Integer, Unicode, Bool,\\n',\n",
       "   ')\\n',\n",
       "   '\\n',\n",
       "   'from jupyter_client.session import Session\\n',\n",
       "   '\\n',\n",
       "   'from ._version import kernel_protocol_version\\n',\n",
       "   '\\n',\n",
       "   'class Kernel(SingletonConfigurable):\\n',\n",
       "   '\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '    # Kernel interface\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    # attribute to override with a GUI\\n',\n",
       "   '    eventloop = Any(None)\\n',\n",
       "   '    def _eventloop_changed(self, name, old, new):\\n',\n",
       "   '        \"\"\"schedule call to eventloop from IOLoop\"\"\"\\n',\n",
       "   '        loop = ioloop.IOLoop.instance()\\n',\n",
       "   '        loop.add_callback(self.enter_eventloop)\\n',\n",
       "   '\\n',\n",
       "   '    session = Instance(Session, allow_none=True)\\n',\n",
       "   \"    profile_dir = Instance('IPython.core.profiledir.ProfileDir', allow_none=True)\\n\",\n",
       "   '    shell_streams = List()\\n',\n",
       "   '    control_stream = Instance(ZMQStream, allow_none=True)\\n',\n",
       "   '    iopub_socket = Any()\\n',\n",
       "   '    iopub_thread = Any()\\n',\n",
       "   '    stdin_socket = Any()\\n',\n",
       "   '    log = Instance(logging.Logger, allow_none=True)\\n',\n",
       "   '\\n',\n",
       "   '    # identities:\\n',\n",
       "   '    int_id = Integer(-1)\\n',\n",
       "   '    ident = Unicode()\\n',\n",
       "   '\\n',\n",
       "   '    def _ident_default(self):\\n',\n",
       "   '        return unicode_type(uuid.uuid4())\\n',\n",
       "   '\\n',\n",
       "   '    # This should be overridden by wrapper kernels that implement any real\\n',\n",
       "   '    # language.\\n',\n",
       "   '    language_info = {}\\n',\n",
       "   '\\n',\n",
       "   '    # any links that should go in the help menu\\n',\n",
       "   '    help_links = List()\\n',\n",
       "   '\\n',\n",
       "   '    # Private interface\\n',\n",
       "   '\\n',\n",
       "   '    _darwin_app_nap = Bool(True, config=True,\\n',\n",
       "   '        help=\"\"\"Whether to use appnope for compatiblity with OS X App Nap.\\n',\n",
       "   '\\n',\n",
       "   '        Only affects OS X >= 10.9.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    # track associations with current request\\n',\n",
       "   '    _allow_stdin = Bool(False)\\n',\n",
       "   '    _parent_header = Dict()\\n',\n",
       "   \"    _parent_ident = Any(b'')\\n\",\n",
       "   '    # Time to sleep after flushing the stdout/err buffers in each execute\\n',\n",
       "   '    # cycle.  While this introduces a hard limit on the minimal latency of the\\n',\n",
       "   '    # execute cycle, it helps prevent output synchronization problems for\\n',\n",
       "   '    # clients.\\n',\n",
       "   '    # Units are in seconds.  The minimum zmq latency on local host is probably\\n',\n",
       "   '    # ~150 microseconds, set this to 500us for now.  We may need to increase it\\n',\n",
       "   \"    # a little if it's not enough after more interactive testing.\\n\",\n",
       "   '    _execute_sleep = Float(0.0005, config=True)\\n',\n",
       "   '\\n',\n",
       "   \"    # Frequency of the kernel's event loop.\\n\",\n",
       "   '    # Units are in seconds, kernel subclasses for GUI toolkits may need to\\n',\n",
       "   '    # adapt to milliseconds.\\n',\n",
       "   '    _poll_interval = Float(0.05, config=True)\\n',\n",
       "   '\\n',\n",
       "   '    # If the shutdown was requested over the network, we leave here the\\n',\n",
       "   '    # necessary reply message so it can be sent by our registered atexit\\n',\n",
       "   '    # handler.  This ensures that the reply is only sent to clients truly at\\n',\n",
       "   '    # the end of our shutdown process (which happens after the underlying\\n',\n",
       "   \"    # IPython shell's own shutdown).\\n\",\n",
       "   '    _shutdown_message = None\\n',\n",
       "   '\\n',\n",
       "   '    # This is a dict of port number that the kernel is listening on. It is set\\n',\n",
       "   '    # by record_ports and used by connect_request.\\n',\n",
       "   '    _recorded_ports = Dict()\\n',\n",
       "   '\\n',\n",
       "   '    # set of aborted msg_ids\\n',\n",
       "   '    aborted = Set()\\n',\n",
       "   '\\n',\n",
       "   '    # Track execution count here. For IPython, we override this to use the\\n',\n",
       "   '    # execution count we store in the shell.\\n',\n",
       "   '    execution_count = 0\\n',\n",
       "   '    \\n',\n",
       "   '    msg_types = [\\n',\n",
       "   \"        'execute_request', 'complete_request',\\n\",\n",
       "   \"        'inspect_request', 'history_request',\\n\",\n",
       "   \"        'comm_info_request', 'kernel_info_request',\\n\",\n",
       "   \"        'connect_request', 'shutdown_request',\\n\",\n",
       "   \"        'is_complete_request',\\n\",\n",
       "   '        # deprecated:\\n',\n",
       "   \"        'apply_request',\\n\",\n",
       "   '    ]\\n',\n",
       "   '    # add deprecated ipyparallel control messages\\n',\n",
       "   \"    control_msg_types = msg_types + ['clear_request', 'abort_request']\\n\",\n",
       "   '\\n',\n",
       "   '    def __init__(self, **kwargs):\\n',\n",
       "   '        super(Kernel, self).__init__(**kwargs)\\n',\n",
       "   '\\n',\n",
       "   '        # Build dict of handlers for message types\\n',\n",
       "   '        self.shell_handlers = {}\\n',\n",
       "   '        for msg_type in self.msg_types:\\n',\n",
       "   '            self.shell_handlers[msg_type] = getattr(self, msg_type)\\n',\n",
       "   '\\n',\n",
       "   '        self.control_handlers = {}\\n',\n",
       "   '        for msg_type in self.control_msg_types:\\n',\n",
       "   '            self.control_handlers[msg_type] = getattr(self, msg_type)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '    def dispatch_control(self, msg):\\n',\n",
       "   '        \"\"\"dispatch control requests\"\"\"\\n',\n",
       "   '        idents,msg = self.session.feed_identities(msg, copy=False)\\n',\n",
       "   '        try:\\n',\n",
       "   '            msg = self.session.deserialize(msg, content=True, copy=False)\\n',\n",
       "   '        except:\\n',\n",
       "   '            self.log.error(\"Invalid Control Message\", exc_info=True)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        self.log.debug(\"Control received: %s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '        # Set the parent message for side effects.\\n',\n",
       "   '        self.set_parent(idents, msg)\\n',\n",
       "   \"        self._publish_status(u'busy')\\n\",\n",
       "   '\\n',\n",
       "   \"        header = msg['header']\\n\",\n",
       "   \"        msg_type = header['msg_type']\\n\",\n",
       "   '\\n',\n",
       "   '        handler = self.control_handlers.get(msg_type, None)\\n',\n",
       "   '        if handler is None:\\n',\n",
       "   '            self.log.error(\"UNKNOWN CONTROL MESSAGE TYPE: %r\", msg_type)\\n',\n",
       "   '        else:\\n',\n",
       "   '            try:\\n',\n",
       "   '                handler(self.control_stream, idents, msg)\\n',\n",
       "   '            except Exception:\\n',\n",
       "   '                self.log.error(\"Exception in control handler:\", exc_info=True)\\n',\n",
       "   '\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   \"        self._publish_status(u'idle')\\n\",\n",
       "   '\\n',\n",
       "   '    def should_handle(self, stream, msg, idents):\\n',\n",
       "   '        \"\"\"Check whether a shell-channel message should be handled\\n',\n",
       "   '        \\n',\n",
       "   '        Allows subclasses to prevent handling of certain messages (e.g. aborted requests).\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        msg_id = msg['header']['msg_id']\\n\",\n",
       "   '        if msg_id in self.aborted:\\n',\n",
       "   \"            msg_type = msg['header']['msg_type']\\n\",\n",
       "   '            # is it safe to assume a msg_id will not be resubmitted?\\n',\n",
       "   '            self.aborted.remove(msg_id)\\n',\n",
       "   \"            reply_type = msg_type.split('_')[0] + '_reply'\\n\",\n",
       "   \"            status = {'status' : 'aborted'}\\n\",\n",
       "   \"            md = {'engine' : self.ident}\\n\",\n",
       "   '            md.update(status)\\n',\n",
       "   '            self.session.send(stream, reply_type, metadata=md,\\n',\n",
       "   '                        content=status, parent=msg, ident=idents)\\n',\n",
       "   '            return False\\n',\n",
       "   '        return True\\n',\n",
       "   '\\n',\n",
       "   '    def dispatch_shell(self, stream, msg):\\n',\n",
       "   '        \"\"\"dispatch shell requests\"\"\"\\n',\n",
       "   '        # flush control requests first\\n',\n",
       "   '        if self.control_stream:\\n',\n",
       "   '            self.control_stream.flush()\\n',\n",
       "   '\\n',\n",
       "   '        idents,msg = self.session.feed_identities(msg, copy=False)\\n',\n",
       "   '        try:\\n',\n",
       "   '            msg = self.session.deserialize(msg, content=True, copy=False)\\n',\n",
       "   '        except:\\n',\n",
       "   '            self.log.error(\"Invalid Message\", exc_info=True)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        # Set the parent message for side effects.\\n',\n",
       "   '        self.set_parent(idents, msg)\\n',\n",
       "   \"        self._publish_status(u'busy')\\n\",\n",
       "   '\\n',\n",
       "   \"        header = msg['header']\\n\",\n",
       "   \"        msg_id = header['msg_id']\\n\",\n",
       "   \"        msg_type = msg['header']['msg_type']\\n\",\n",
       "   '\\n',\n",
       "   \"        # Print some info about this message and leave a '--->' marker, so it's\\n\",\n",
       "   '        # easier to trace visually the message chain when debugging.  Each\\n',\n",
       "   '        # handler prints its message at the end.\\n',\n",
       "   \"        self.log.debug('\\\\n*** MESSAGE TYPE:%s***', msg_type)\\n\",\n",
       "   \"        self.log.debug('   Content: %s\\\\n   --->\\\\n   ', msg['content'])\\n\",\n",
       "   '\\n',\n",
       "   '        if not self.should_handle(stream, msg, idents):\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        handler = self.shell_handlers.get(msg_type, None)\\n',\n",
       "   '        if handler is None:\\n',\n",
       "   '            self.log.error(\"UNKNOWN MESSAGE TYPE: %r\", msg_type)\\n',\n",
       "   '        else:\\n',\n",
       "   '            self.log.debug(\"%s: %s\", msg_type, msg)\\n',\n",
       "   '            self.pre_handler_hook()\\n',\n",
       "   '            try:\\n',\n",
       "   '                handler(stream, idents, msg)\\n',\n",
       "   '            except Exception:\\n',\n",
       "   '                self.log.error(\"Exception in message handler:\", exc_info=True)\\n',\n",
       "   '            finally:\\n',\n",
       "   '                self.post_handler_hook()\\n',\n",
       "   '\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   \"        self._publish_status(u'idle')\\n\",\n",
       "   '\\n',\n",
       "   '    def pre_handler_hook(self):\\n',\n",
       "   '        \"\"\"Hook to execute before calling message handler\"\"\"\\n',\n",
       "   '        # ensure default_int_handler during handler call\\n',\n",
       "   '        self.saved_sigint_handler = signal(SIGINT, default_int_handler)\\n',\n",
       "   '\\n',\n",
       "   '    def post_handler_hook(self):\\n',\n",
       "   '        \"\"\"Hook to execute after calling message handler\"\"\"\\n',\n",
       "   '        signal(SIGINT, self.saved_sigint_handler)\\n',\n",
       "   '\\n',\n",
       "   '    def enter_eventloop(self):\\n',\n",
       "   '        \"\"\"enter eventloop\"\"\"\\n',\n",
       "   '        self.log.info(\"entering eventloop %s\", self.eventloop)\\n',\n",
       "   '        for stream in self.shell_streams:\\n',\n",
       "   '            # flush any pending replies,\\n',\n",
       "   '            # which may be skipped by entering the eventloop\\n',\n",
       "   '            stream.flush(zmq.POLLOUT)\\n',\n",
       "   '        # restore default_int_handler\\n',\n",
       "   '        signal(SIGINT, default_int_handler)\\n',\n",
       "   '        while self.eventloop is not None:\\n',\n",
       "   '            try:\\n',\n",
       "   '                self.eventloop(self)\\n',\n",
       "   '            except KeyboardInterrupt:\\n',\n",
       "   \"                # Ctrl-C shouldn't crash the kernel\\n\",\n",
       "   '                self.log.error(\"KeyboardInterrupt caught in kernel\")\\n',\n",
       "   '                continue\\n',\n",
       "   '            else:\\n',\n",
       "   '                # eventloop exited cleanly, this means we should stop (right?)\\n',\n",
       "   '                self.eventloop = None\\n',\n",
       "   '                break\\n',\n",
       "   '        self.log.info(\"exiting eventloop\")\\n',\n",
       "   '\\n',\n",
       "   '    def start(self):\\n',\n",
       "   '        \"\"\"register dispatchers for streams\"\"\"\\n',\n",
       "   '        if self.control_stream:\\n',\n",
       "   '            self.control_stream.on_recv(self.dispatch_control, copy=False)\\n',\n",
       "   '\\n',\n",
       "   '        def make_dispatcher(stream):\\n',\n",
       "   '            def dispatcher(msg):\\n',\n",
       "   '                return self.dispatch_shell(stream, msg)\\n',\n",
       "   '            return dispatcher\\n',\n",
       "   '\\n',\n",
       "   '        for s in self.shell_streams:\\n',\n",
       "   '            s.on_recv(make_dispatcher(s), copy=False)\\n',\n",
       "   '\\n',\n",
       "   '        # publish idle status\\n',\n",
       "   \"        self._publish_status('starting')\\n\",\n",
       "   '\\n',\n",
       "   '    def do_one_iteration(self):\\n',\n",
       "   '        \"\"\"step eventloop just once\"\"\"\\n',\n",
       "   '        if self.control_stream:\\n',\n",
       "   '            self.control_stream.flush()\\n',\n",
       "   '        for stream in self.shell_streams:\\n',\n",
       "   '            # handle at most one request per iteration\\n',\n",
       "   '            stream.flush(zmq.POLLIN, 1)\\n',\n",
       "   '            stream.flush(zmq.POLLOUT)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '    def record_ports(self, ports):\\n',\n",
       "   '        \"\"\"Record the ports that this kernel is using.\\n',\n",
       "   '\\n',\n",
       "   '        The creator of the Kernel instance must call this methods if they\\n',\n",
       "   '        want the :meth:`connect_request` method to return the port numbers.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        self._recorded_ports = ports\\n',\n",
       "   '\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '    # Kernel request handlers\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def _publish_execute_input(self, code, parent, execution_count):\\n',\n",
       "   '        \"\"\"Publish the code request on the iopub stream.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   \"        self.session.send(self.iopub_socket, u'execute_input',\\n\",\n",
       "   \"                            {u'code':code, u'execution_count': execution_count},\\n\",\n",
       "   \"                            parent=parent, ident=self._topic('execute_input')\\n\",\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '    def _publish_status(self, status, parent=None):\\n',\n",
       "   '        \"\"\"send status (busy/idle) on IOPub\"\"\"\\n',\n",
       "   '        self.session.send(self.iopub_socket,\\n',\n",
       "   \"                          u'status',\\n\",\n",
       "   \"                          {u'execution_state': status},\\n\",\n",
       "   '                          parent=parent or self._parent_header,\\n',\n",
       "   \"                          ident=self._topic('status'),\\n\",\n",
       "   '                          )\\n',\n",
       "   '\\n',\n",
       "   '    def set_parent(self, ident, parent):\\n',\n",
       "   '        \"\"\"Set the current parent_header\\n',\n",
       "   '\\n',\n",
       "   '        Side effects (IOPub messages) and replies are associated with\\n',\n",
       "   '        the request that caused them via the parent_header.\\n',\n",
       "   '\\n',\n",
       "   '        The parent identity is used to route input_request messages\\n',\n",
       "   '        on the stdin channel.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        self._parent_ident = ident\\n',\n",
       "   '        self._parent_header = parent\\n',\n",
       "   '\\n',\n",
       "   '    def send_response(self, stream, msg_or_type, content=None, ident=None,\\n',\n",
       "   '             buffers=None, track=False, header=None, metadata=None):\\n',\n",
       "   '        \"\"\"Send a response to the message we\\'re currently processing.\\n',\n",
       "   '\\n',\n",
       "   '        This accepts all the parameters of :meth:`jupyter_client.session.Session.send`\\n',\n",
       "   '        except ``parent``.\\n',\n",
       "   '\\n',\n",
       "   '        This relies on :meth:`set_parent` having been called for the current\\n',\n",
       "   '        message.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        return self.session.send(stream, msg_or_type, content, self._parent_header,\\n',\n",
       "   '                                 ident, buffers, track, header, metadata)\\n',\n",
       "   '    \\n',\n",
       "   '    def init_metadata(self, parent):\\n',\n",
       "   '        \"\"\"Initialize metadata.\\n',\n",
       "   '        \\n',\n",
       "   '        Run at the beginning of execution requests.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        return {\\n',\n",
       "   \"            'started': datetime.now(),\\n\",\n",
       "   '        }\\n',\n",
       "   '    \\n',\n",
       "   '    def finish_metadata(self, parent, metadata, reply_content):\\n',\n",
       "   '        \"\"\"Finish populating metadata.\\n',\n",
       "   '        \\n',\n",
       "   '        Run after completing an execution request.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        return metadata\\n',\n",
       "   '\\n',\n",
       "   '    def execute_request(self, stream, ident, parent):\\n',\n",
       "   '        \"\"\"handle an execute_request\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   \"            content = parent[u'content']\\n\",\n",
       "   \"            code = py3compat.cast_unicode_py2(content[u'code'])\\n\",\n",
       "   \"            silent = content[u'silent']\\n\",\n",
       "   \"            store_history = content.get(u'store_history', not silent)\\n\",\n",
       "   \"            user_expressions = content.get('user_expressions', {})\\n\",\n",
       "   \"            allow_stdin = content.get('allow_stdin', False)\\n\",\n",
       "   '        except:\\n',\n",
       "   '            self.log.error(\"Got bad msg: \")\\n',\n",
       "   '            self.log.error(\"%s\", parent)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   \"        stop_on_error = content.get('stop_on_error', True)\\n\",\n",
       "   '\\n',\n",
       "   '        metadata = self.init_metadata(parent)\\n',\n",
       "   '\\n',\n",
       "   '        # Re-broadcast our input for the benefit of listening clients, and\\n',\n",
       "   '        # start computing output\\n',\n",
       "   '        if not silent:\\n',\n",
       "   '            self.execution_count += 1\\n',\n",
       "   '            self._publish_execute_input(code, parent, self.execution_count)\\n',\n",
       "   '\\n',\n",
       "   '        reply_content = self.do_execute(code, silent, store_history,\\n',\n",
       "   '                                        user_expressions, allow_stdin)\\n',\n",
       "   '\\n',\n",
       "   '        # Flush output before sending the reply.\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   \"        # FIXME: on rare occasions, the flush doesn't seem to make it to the\\n\",\n",
       "   '        # clients... This seems to mitigate the problem, but we definitely need\\n',\n",
       "   \"        # to better understand what's going on.\\n\",\n",
       "   '        if self._execute_sleep:\\n',\n",
       "   '            time.sleep(self._execute_sleep)\\n',\n",
       "   '\\n',\n",
       "   '        # Send the reply.\\n',\n",
       "   '        reply_content = json_clean(reply_content)\\n',\n",
       "   '        metadata = self.finish_metadata(parent, metadata, reply_content)\\n',\n",
       "   '\\n',\n",
       "   \"        reply_msg = self.session.send(stream, u'execute_reply',\\n\",\n",
       "   '                                      reply_content, parent, metadata=metadata,\\n',\n",
       "   '                                      ident=ident)\\n',\n",
       "   '\\n',\n",
       "   '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "   '\\n',\n",
       "   \"        if not silent and reply_msg['content']['status'] == u'error' and stop_on_error:\\n\",\n",
       "   '            self._abort_queues()\\n',\n",
       "   '\\n',\n",
       "   '    def do_execute(self, code, silent, store_history=True,\\n',\n",
       "   '                   user_expressions=None, allow_stdin=False):\\n',\n",
       "   '        \"\"\"Execute user code. Must be overridden by subclasses.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    def complete_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = parent['content']\\n\",\n",
       "   \"        code = content['code']\\n\",\n",
       "   \"        cursor_pos = content['cursor_pos']\\n\",\n",
       "   '\\n',\n",
       "   '        matches = self.do_complete(code, cursor_pos)\\n',\n",
       "   '        matches = json_clean(matches)\\n',\n",
       "   \"        completion_msg = self.session.send(stream, 'complete_reply',\\n\",\n",
       "   '                                           matches, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", completion_msg)\\n',\n",
       "   '\\n',\n",
       "   '    def do_complete(self, code, cursor_pos):\\n',\n",
       "   '        \"\"\"Override in subclasses to find completions.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return {'matches' : [],\\n\",\n",
       "   \"                'cursor_end' : cursor_pos,\\n\",\n",
       "   \"                'cursor_start' : cursor_pos,\\n\",\n",
       "   \"                'metadata' : {},\\n\",\n",
       "   \"                'status' : 'ok'}\\n\",\n",
       "   '\\n',\n",
       "   '    def inspect_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = parent['content']\\n\",\n",
       "   '\\n',\n",
       "   \"        reply_content = self.do_inspect(content['code'], content['cursor_pos'],\\n\",\n",
       "   \"                                        content.get('detail_level', 0))\\n\",\n",
       "   '        # Before we send this object over, we scrub it for JSON usage\\n',\n",
       "   '        reply_content = json_clean(reply_content)\\n',\n",
       "   \"        msg = self.session.send(stream, 'inspect_reply',\\n\",\n",
       "   '                                reply_content, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '    def do_inspect(self, code, cursor_pos, detail_level=0):\\n',\n",
       "   '        \"\"\"Override in subclasses to allow introspection.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return {'status': 'ok', 'data': {}, 'metadata': {}, 'found': False}\\n\",\n",
       "   '\\n',\n",
       "   '    def history_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = parent['content']\\n\",\n",
       "   '\\n',\n",
       "   '        reply_content = self.do_history(**content)\\n',\n",
       "   '\\n',\n",
       "   '        reply_content = json_clean(reply_content)\\n',\n",
       "   \"        msg = self.session.send(stream, 'history_reply',\\n\",\n",
       "   '                                reply_content, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '    def do_history(self, hist_access_type, output, raw, session=None, start=None,\\n',\n",
       "   '                   stop=None, n=None, pattern=None, unique=False):\\n',\n",
       "   '        \"\"\"Override in subclasses to access history.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return {'history': []}\\n\",\n",
       "   '\\n',\n",
       "   '    def connect_request(self, stream, ident, parent):\\n',\n",
       "   '        if self._recorded_ports is not None:\\n',\n",
       "   '            content = self._recorded_ports.copy()\\n',\n",
       "   '        else:\\n',\n",
       "   '            content = {}\\n',\n",
       "   \"        msg = self.session.send(stream, 'connect_reply',\\n\",\n",
       "   '                                content, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '    @property\\n',\n",
       "   '    def kernel_info(self):\\n',\n",
       "   '        return {\\n',\n",
       "   \"            'protocol_version': kernel_protocol_version,\\n\",\n",
       "   \"            'implementation': self.implementation,\\n\",\n",
       "   \"            'implementation_version': self.implementation_version,\\n\",\n",
       "   \"            'language_info': self.language_info,\\n\",\n",
       "   \"            'banner': self.banner,\\n\",\n",
       "   \"            'help_links': self.help_links,\\n\",\n",
       "   '        }\\n',\n",
       "   '\\n',\n",
       "   '    def kernel_info_request(self, stream, ident, parent):\\n',\n",
       "   \"        msg = self.session.send(stream, 'kernel_info_reply',\\n\",\n",
       "   '                                self.kernel_info, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '    def comm_info_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = parent['content']\\n\",\n",
       "   \"        target_name = content.get('target_name', None)\\n\",\n",
       "   '\\n',\n",
       "   '        # Should this be moved to ipkernel?\\n',\n",
       "   \"        if hasattr(self, 'comm_manager'):\\n\",\n",
       "   '            comms = {\\n',\n",
       "   '                k: dict(target_name=v.target_name)\\n',\n",
       "   '                for (k, v) in self.comm_manager.comms.items()\\n',\n",
       "   '                if v.target_name == target_name or target_name is None\\n',\n",
       "   '            }\\n',\n",
       "   '        else:\\n',\n",
       "   '            comms = {}\\n',\n",
       "   '        reply_content = dict(comms=comms)\\n',\n",
       "   \"        msg = self.session.send(stream, 'comm_info_reply',\\n\",\n",
       "   '                                reply_content, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", msg)\\n',\n",
       "   '\\n',\n",
       "   '    def shutdown_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = self.do_shutdown(parent['content']['restart'])\\n\",\n",
       "   \"        self.session.send(stream, u'shutdown_reply', content, parent, ident=ident)\\n\",\n",
       "   '        # same content, but different msg_id for broadcasting on IOPub\\n',\n",
       "   \"        self._shutdown_message = self.session.msg(u'shutdown_reply',\\n\",\n",
       "   '                                                  content, parent\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '        self._at_shutdown()\\n',\n",
       "   '        # call sys.exit after a short delay\\n',\n",
       "   '        loop = ioloop.IOLoop.instance()\\n',\n",
       "   '        loop.add_timeout(time.time()+0.1, loop.stop)\\n',\n",
       "   '\\n',\n",
       "   '    def do_shutdown(self, restart):\\n',\n",
       "   '        \"\"\"Override in subclasses to do things when the frontend shuts down the\\n',\n",
       "   '        kernel.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return {'status': 'ok', 'restart': restart}\\n\",\n",
       "   '\\n',\n",
       "   '    def is_complete_request(self, stream, ident, parent):\\n',\n",
       "   \"        content = parent['content']\\n\",\n",
       "   \"        code = content['code']\\n\",\n",
       "   '\\n',\n",
       "   '        reply_content = self.do_is_complete(code)\\n',\n",
       "   '        reply_content = json_clean(reply_content)\\n',\n",
       "   \"        reply_msg = self.session.send(stream, 'is_complete_reply',\\n\",\n",
       "   '                                           reply_content, parent, ident)\\n',\n",
       "   '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "   '\\n',\n",
       "   '    def do_is_complete(self, code):\\n',\n",
       "   '        \"\"\"Override in subclasses to find completions.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return {'status' : 'unknown',\\n\",\n",
       "   '                }\\n',\n",
       "   '\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '    # Engine methods (DEPRECATED)\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def apply_request(self, stream, ident, parent):\\n',\n",
       "   '        self.log.warn(\"\"\"apply_request is deprecated in kernel_base, moving to ipyparallel.\"\"\")\\n',\n",
       "   '        try:\\n',\n",
       "   \"            content = parent[u'content']\\n\",\n",
       "   \"            bufs = parent[u'buffers']\\n\",\n",
       "   \"            msg_id = parent['header']['msg_id']\\n\",\n",
       "   '        except:\\n',\n",
       "   '            self.log.error(\"Got bad msg: %s\", parent, exc_info=True)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        md = self.init_metadata(parent)\\n',\n",
       "   '\\n',\n",
       "   '        reply_content, result_buf = self.do_apply(content, bufs, msg_id, md)\\n',\n",
       "   '        \\n',\n",
       "   '        # flush i/o\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   '\\n',\n",
       "   '        md = self.finish_metadata(parent, md, reply_content)\\n',\n",
       "   '\\n',\n",
       "   \"        self.session.send(stream, u'apply_reply', reply_content,\\n\",\n",
       "   '                    parent=parent, ident=ident,buffers=result_buf, metadata=md)\\n',\n",
       "   '\\n',\n",
       "   '    def do_apply(self, content, bufs, msg_id, reply_metadata):\\n',\n",
       "   '        \"\"\"DEPRECATED\"\"\"\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '    # Control messages (DEPRECATED)\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def abort_request(self, stream, ident, parent):\\n',\n",
       "   '        \"\"\"abort a specific msg by id\"\"\"\\n',\n",
       "   '        self.log.warn(\"abort_request is deprecated in kernel_base. It os only part of IPython parallel\")\\n',\n",
       "   \"        msg_ids = parent['content'].get('msg_ids', None)\\n\",\n",
       "   '        if isinstance(msg_ids, string_types):\\n',\n",
       "   '            msg_ids = [msg_ids]\\n',\n",
       "   '        if not msg_ids:\\n',\n",
       "   '            self._abort_queues()\\n',\n",
       "   '        for mid in msg_ids:\\n',\n",
       "   '            self.aborted.add(str(mid))\\n',\n",
       "   '\\n',\n",
       "   \"        content = dict(status='ok')\\n\",\n",
       "   \"        reply_msg = self.session.send(stream, 'abort_reply', content=content,\\n\",\n",
       "   '                parent=parent, ident=ident)\\n',\n",
       "   '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "   '\\n',\n",
       "   '    def clear_request(self, stream, idents, parent):\\n',\n",
       "   '        \"\"\"Clear our namespace.\"\"\"\\n',\n",
       "   '        self.log.warn(\"clear_request is deprecated in kernel_base. It os only part of IPython parallel\")\\n',\n",
       "   '        content = self.do_clear()\\n',\n",
       "   \"        self.session.send(stream, 'clear_reply', ident=idents, parent=parent,\\n\",\n",
       "   '                content = content)\\n',\n",
       "   '\\n',\n",
       "   '    def do_clear(self):\\n',\n",
       "   '        \"\"\"DEPRECATED\"\"\"\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '    # Protected interface\\n',\n",
       "   '    #---------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def _topic(self, topic):\\n',\n",
       "   '        \"\"\"prefixed topic for IOPub messages\"\"\"\\n',\n",
       "   '        base = \"kernel.%s\" % self.ident\\n',\n",
       "   '\\n',\n",
       "   '        return py3compat.cast_bytes(\"%s.%s\" % (base, topic))\\n',\n",
       "   '\\n',\n",
       "   '    def _abort_queues(self):\\n',\n",
       "   '        for stream in self.shell_streams:\\n',\n",
       "   '            if stream:\\n',\n",
       "   '                self._abort_queue(stream)\\n',\n",
       "   '\\n',\n",
       "   '    def _abort_queue(self, stream):\\n',\n",
       "   '        poller = zmq.Poller()\\n',\n",
       "   '        poller.register(stream.socket, zmq.POLLIN)\\n',\n",
       "   '        while True:\\n',\n",
       "   '            idents,msg = self.session.recv(stream, zmq.NOBLOCK, content=True)\\n',\n",
       "   '            if msg is None:\\n',\n",
       "   '                return\\n',\n",
       "   '\\n',\n",
       "   '            self.log.info(\"Aborting:\")\\n',\n",
       "   '            self.log.info(\"%s\", msg)\\n',\n",
       "   \"            msg_type = msg['header']['msg_type']\\n\",\n",
       "   \"            reply_type = msg_type.split('_')[0] + '_reply'\\n\",\n",
       "   '\\n',\n",
       "   \"            status = {'status' : 'aborted'}\\n\",\n",
       "   \"            md = {'engine' : self.ident}\\n\",\n",
       "   '            md.update(status)\\n',\n",
       "   '            reply_msg = self.session.send(stream, reply_type, metadata=md,\\n',\n",
       "   '                        content=status, parent=msg, ident=idents)\\n',\n",
       "   '            self.log.debug(\"%s\", reply_msg)\\n',\n",
       "   '            # We need to wait a bit for requests to come in. This can probably\\n',\n",
       "   '            # be set shorter for true asynchronous clients.\\n',\n",
       "   '            poller.poll(50)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '    def _no_raw_input(self):\\n',\n",
       "   '        \"\"\"Raise StdinNotImplentedError if active frontend doesn\\'t support\\n',\n",
       "   '        stdin.\"\"\"\\n',\n",
       "   '        raise StdinNotImplementedError(\"raw_input was called, but this \"\\n',\n",
       "   '                                       \"frontend does not support stdin.\")\\n',\n",
       "   '\\n',\n",
       "   \"    def getpass(self, prompt=''):\\n\",\n",
       "   '        \"\"\"Forward getpass to frontends\\n',\n",
       "   '\\n',\n",
       "   '        Raises\\n',\n",
       "   '        ------\\n',\n",
       "   \"        StdinNotImplentedError if active frontend doesn't support stdin.\\n\",\n",
       "   '        \"\"\"\\n',\n",
       "   '        if not self._allow_stdin:\\n',\n",
       "   '            raise StdinNotImplementedError(\\n',\n",
       "   '                \"getpass was called, but this frontend does not support input requests.\"\\n',\n",
       "   '            )\\n',\n",
       "   '        return self._input_request(prompt,\\n',\n",
       "   '            self._parent_ident,\\n',\n",
       "   '            self._parent_header,\\n',\n",
       "   '            password=True,\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   \"    def raw_input(self, prompt=''):\\n\",\n",
       "   '        \"\"\"Forward raw_input to frontends\\n',\n",
       "   '\\n',\n",
       "   '        Raises\\n',\n",
       "   '        ------\\n',\n",
       "   \"        StdinNotImplentedError if active frontend doesn't support stdin.\\n\",\n",
       "   '        \"\"\"\\n',\n",
       "   '        if not self._allow_stdin:\\n',\n",
       "   '            raise StdinNotImplementedError(\\n',\n",
       "   '                \"raw_input was called, but this frontend does not support input requests.\"\\n',\n",
       "   '            )\\n',\n",
       "   '        return self._input_request(prompt,\\n',\n",
       "   '            self._parent_ident,\\n',\n",
       "   '            self._parent_header,\\n',\n",
       "   '            password=False,\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '    def _input_request(self, prompt, ident, parent, password=False):\\n',\n",
       "   '        # Flush output before making the request.\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        # flush the stdin socket, to purge stale replies\\n',\n",
       "   '        while True:\\n',\n",
       "   '            try:\\n',\n",
       "   '                self.stdin_socket.recv_multipart(zmq.NOBLOCK)\\n',\n",
       "   '            except zmq.ZMQError as e:\\n',\n",
       "   '                if e.errno == zmq.EAGAIN:\\n',\n",
       "   '                    break\\n',\n",
       "   '                else:\\n',\n",
       "   '                    raise\\n',\n",
       "   '\\n',\n",
       "   '        # Send the input request.\\n',\n",
       "   '        content = json_clean(dict(prompt=prompt, password=password))\\n',\n",
       "   \"        self.session.send(self.stdin_socket, u'input_request', content, parent,\\n\",\n",
       "   '                          ident=ident)\\n',\n",
       "   '\\n',\n",
       "   '        # Await a response.\\n',\n",
       "   '        while True:\\n',\n",
       "   '            try:\\n',\n",
       "   '                ident, reply = self.session.recv(self.stdin_socket, 0)\\n',\n",
       "   '            except Exception:\\n',\n",
       "   '                self.log.warn(\"Invalid Message:\", exc_info=True)\\n',\n",
       "   '            except KeyboardInterrupt:\\n',\n",
       "   '                # re-raise KeyboardInterrupt, to truncate traceback\\n',\n",
       "   '                raise KeyboardInterrupt\\n',\n",
       "   '            else:\\n',\n",
       "   '                break\\n',\n",
       "   '        try:\\n',\n",
       "   \"            value = py3compat.unicode_to_str(reply['content']['value'])\\n\",\n",
       "   '        except:\\n',\n",
       "   '            self.log.error(\"Bad input_reply: %s\", parent)\\n',\n",
       "   \"            value = ''\\n\",\n",
       "   \"        if value == '\\\\x04':\\n\",\n",
       "   '            # EOF\\n',\n",
       "   '            raise EOFError\\n',\n",
       "   '        return value\\n',\n",
       "   '\\n',\n",
       "   '    def _at_shutdown(self):\\n',\n",
       "   '        \"\"\"Actions taken at shutdown by the kernel, called by python\\'s atexit.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        # io.rprint(\"Kernel at_shutdown\") # dbg\\n',\n",
       "   '        if self._shutdown_message is not None:\\n',\n",
       "   \"            self.session.send(self.iopub_socket, self._shutdown_message, ident=self._topic('shutdown'))\\n\",\n",
       "   '            self.log.debug(\"%s\", self._shutdown_message)\\n',\n",
       "   '        [ s.flush(zmq.POLLOUT) for s in self.shell_streams ]\\n'],\n",
       "  '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/kernelbase.py'),\n",
       " {'_allow_stdin': True,\n",
       "  '_darwin_app_nap': True,\n",
       "  '_execute_sleep': 0.0005,\n",
       "  '_parent_header': {'buffers': [],\n",
       "   'content': {'allow_stdin': True,\n",
       "    'code': 'gc.get_objects()',\n",
       "    'silent': False,\n",
       "    'stop_on_error': True,\n",
       "    'store_history': True,\n",
       "    'user_expressions': {}},\n",
       "   'header': {'date': '2016-03-20T19:46:05.318327',\n",
       "    'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "    'msg_type': 'execute_request',\n",
       "    'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "    'username': 'username',\n",
       "    'version': '5.0'},\n",
       "   'metadata': {},\n",
       "   'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'parent_header': {}},\n",
       "  '_parent_ident': [b'4CE6797D9E26478A800FA96DD84CCB50'],\n",
       "  '_poll_interval': 0.05,\n",
       "  '_recorded_ports': {'control': 42492,\n",
       "   'hb': 39269,\n",
       "   'iopub': 54629,\n",
       "   'shell': 39890,\n",
       "   'stdin': 58359},\n",
       "  '_sys_eval_input': None,\n",
       "  '_sys_raw_input': <function input>,\n",
       "  'aborted': set(),\n",
       "  'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'control_stream': None,\n",
       "  'eventloop': None,\n",
       "  'help_links': [{'text': 'Python', 'url': 'http://docs.python.org/3.4'},\n",
       "   {'text': 'IPython', 'url': 'http://ipython.org/documentation.html'},\n",
       "   {'text': 'NumPy', 'url': 'http://docs.scipy.org/doc/numpy/reference/'},\n",
       "   {'text': 'SciPy', 'url': 'http://docs.scipy.org/doc/scipy/reference/'},\n",
       "   {'text': 'Matplotlib', 'url': 'http://matplotlib.org/contents.html'},\n",
       "   {'text': 'SymPy', 'url': 'http://docs.sympy.org/latest/index.html'},\n",
       "   {'text': 'pandas', 'url': 'http://pandas.pydata.org/pandas-docs/stable/'}],\n",
       "  'ident': '60debbe5-9e37-44be-8878-88c400d6728c',\n",
       "  'int_id': -1,\n",
       "  'iopub_socket': <ipykernel.iostream.BackgroundSocket at 0x7f51c124bdd8>,\n",
       "  'iopub_thread': <ipykernel.iostream.IOPubThread at 0x7f51c124be48>,\n",
       "  'log': <logging.Logger at 0x7f51d2a1aba8>,\n",
       "  'parent': <ipykernel.kernelapp.IPKernelApp at 0x7f51d2a1ac18>,\n",
       "  'profile_dir': <IPython.core.profiledir.ProfileDir at 0x7f51c1221518>,\n",
       "  'session': <jupyter_client.session.Session at 0x7f51c124be10>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "  'shell_class': ipykernel.zmqshell.ZMQInteractiveShell,\n",
       "  'shell_streams': [<zmq.eventloop.zmqstream.ZMQStream at 0x7f51c12216d8>,\n",
       "   <zmq.eventloop.zmqstream.ZMQStream at 0x7f51c1221358>],\n",
       "  'stdin_socket': <zmq.sugar.socket.Socket at 0x7f51c11ead08>,\n",
       "  'user_module': None,\n",
       "  'user_ns': None},\n",
       " (14435,\n",
       "  1457880526.3519778,\n",
       "  ['\"\"\"The IPython kernel implementation\"\"\"\\n',\n",
       "   '\\n',\n",
       "   'import getpass\\n',\n",
       "   'import sys\\n',\n",
       "   'import traceback\\n',\n",
       "   '\\n',\n",
       "   'from IPython.core import release\\n',\n",
       "   'from ipython_genutils.py3compat import builtin_mod, PY3\\n',\n",
       "   'from IPython.utils.tokenutil import token_at_cursor, line_at_cursor\\n',\n",
       "   'from traitlets import Instance, Type, Any, List\\n',\n",
       "   '\\n',\n",
       "   'from .comm import CommManager\\n',\n",
       "   'from .kernelbase import Kernel as KernelBase\\n',\n",
       "   'from .zmqshell import ZMQInteractiveShell\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class IPythonKernel(KernelBase):\\n',\n",
       "   \"    shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',\\n\",\n",
       "   '                     allow_none=True)\\n',\n",
       "   '    shell_class = Type(ZMQInteractiveShell)\\n',\n",
       "   '\\n',\n",
       "   '    user_module = Any()\\n',\n",
       "   '    def _user_module_changed(self, name, old, new):\\n',\n",
       "   '        if self.shell is not None:\\n',\n",
       "   '            self.shell.user_module = new\\n',\n",
       "   '\\n',\n",
       "   '    user_ns = Instance(dict, args=None, allow_none=True)\\n',\n",
       "   '    def _user_ns_changed(self, name, old, new):\\n',\n",
       "   '        if self.shell is not None:\\n',\n",
       "   '            self.shell.user_ns = new\\n',\n",
       "   '            self.shell.init_user_ns()\\n',\n",
       "   '\\n',\n",
       "   \"    # A reference to the Python builtin 'raw_input' function.\\n\",\n",
       "   '    # (i.e., __builtin__.raw_input for Python 2.7, builtins.input for Python 3)\\n',\n",
       "   '    _sys_raw_input = Any()\\n',\n",
       "   '    _sys_eval_input = Any()\\n',\n",
       "   '\\n',\n",
       "   '    def __init__(self, **kwargs):\\n',\n",
       "   '        super(IPythonKernel, self).__init__(**kwargs)\\n',\n",
       "   '\\n',\n",
       "   '        # Initialize the InteractiveShell subclass\\n',\n",
       "   '        self.shell = self.shell_class.instance(parent=self,\\n',\n",
       "   '            profile_dir = self.profile_dir,\\n',\n",
       "   '            user_module = self.user_module,\\n',\n",
       "   '            user_ns     = self.user_ns,\\n',\n",
       "   '            kernel      = self,\\n',\n",
       "   '        )\\n',\n",
       "   '        self.shell.displayhook.session = self.session\\n',\n",
       "   '        self.shell.displayhook.pub_socket = self.iopub_socket\\n',\n",
       "   \"        self.shell.displayhook.topic = self._topic('execute_result')\\n\",\n",
       "   '        self.shell.display_pub.session = self.session\\n',\n",
       "   '        self.shell.display_pub.pub_socket = self.iopub_socket\\n',\n",
       "   '\\n',\n",
       "   '        # TMP - hack while developing\\n',\n",
       "   '        self.shell._reply_content = None\\n',\n",
       "   '\\n',\n",
       "   '        self.comm_manager = CommManager(shell=self.shell, parent=self,\\n',\n",
       "   '                                        kernel=self)\\n',\n",
       "   '\\n',\n",
       "   '        self.shell.configurables.append(self.comm_manager)\\n',\n",
       "   \"        comm_msg_types = [ 'comm_open', 'comm_msg', 'comm_close' ]\\n\",\n",
       "   '        for msg_type in comm_msg_types:\\n',\n",
       "   '            self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)\\n',\n",
       "   '\\n',\n",
       "   '    help_links = List([\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"Python\",\\n',\n",
       "   '            \\'url\\': \"http://docs.python.org/%i.%i\" % sys.version_info[:2],\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"IPython\",\\n',\n",
       "   '            \\'url\\': \"http://ipython.org/documentation.html\",\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"NumPy\",\\n',\n",
       "   '            \\'url\\': \"http://docs.scipy.org/doc/numpy/reference/\",\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"SciPy\",\\n',\n",
       "   '            \\'url\\': \"http://docs.scipy.org/doc/scipy/reference/\",\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"Matplotlib\",\\n',\n",
       "   '            \\'url\\': \"http://matplotlib.org/contents.html\",\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"SymPy\",\\n',\n",
       "   '            \\'url\\': \"http://docs.sympy.org/latest/index.html\",\\n',\n",
       "   '        },\\n',\n",
       "   '        {\\n',\n",
       "   '            \\'text\\': \"pandas\",\\n',\n",
       "   '            \\'url\\': \"http://pandas.pydata.org/pandas-docs/stable/\",\\n',\n",
       "   '        },\\n',\n",
       "   '    ])\\n',\n",
       "   '\\n',\n",
       "   '    # Kernel info fields\\n',\n",
       "   \"    implementation = 'ipython'\\n\",\n",
       "   '    implementation_version = release.version\\n',\n",
       "   '    language_info = {\\n',\n",
       "   \"                     'name': 'python',\\n\",\n",
       "   \"                     'version': sys.version.split()[0],\\n\",\n",
       "   \"                     'mimetype': 'text/x-python',\\n\",\n",
       "   \"                     'codemirror_mode': {'name': 'ipython',\\n\",\n",
       "   \"                                         'version': sys.version_info[0]},\\n\",\n",
       "   \"                     'pygments_lexer': 'ipython%d' % (3 if PY3 else 2),\\n\",\n",
       "   \"                     'nbconvert_exporter': 'python',\\n\",\n",
       "   \"                     'file_extension': '.py'\\n\",\n",
       "   '                    }\\n',\n",
       "   '    @property\\n',\n",
       "   '    def banner(self):\\n',\n",
       "   '        return self.shell.banner\\n',\n",
       "   '\\n',\n",
       "   '    def start(self):\\n',\n",
       "   '        self.shell.exit_now = False\\n',\n",
       "   '        super(IPythonKernel, self).start()\\n',\n",
       "   '\\n',\n",
       "   '    def set_parent(self, ident, parent):\\n',\n",
       "   '        \"\"\"Overridden from parent to tell the display hook and output streams\\n',\n",
       "   '        about the parent message.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        super(IPythonKernel, self).set_parent(ident, parent)\\n',\n",
       "   '        self.shell.set_parent(parent)\\n',\n",
       "   '\\n',\n",
       "   '    def init_metadata(self, parent):\\n',\n",
       "   '        \"\"\"Initialize metadata.\\n',\n",
       "   '        \\n',\n",
       "   '        Run at the beginning of each execution request.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        md = super(IPythonKernel, self).init_metadata(parent)\\n',\n",
       "   '        # FIXME: remove deprecated ipyparallel-specific code\\n',\n",
       "   '        # This is required for ipyparallel < 5.0\\n',\n",
       "   '        md.update({\\n',\n",
       "   \"            'dependencies_met' : True,\\n\",\n",
       "   \"            'engine' : self.ident,\\n\",\n",
       "   '        })\\n',\n",
       "   '        return md\\n',\n",
       "   '    \\n',\n",
       "   '    def finish_metadata(self, parent, metadata, reply_content):\\n',\n",
       "   '        \"\"\"Finish populating metadata.\\n',\n",
       "   '        \\n',\n",
       "   '        Run after completing an execution request.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        # FIXME: remove deprecated ipyparallel-specific code\\n',\n",
       "   '        # This is required by ipyparallel < 5.0\\n',\n",
       "   \"        metadata['status'] = reply_content['status']\\n\",\n",
       "   \"        if reply_content['status'] == 'error' and reply_content['ename'] == 'UnmetDependency':\\n\",\n",
       "   \"                metadata['dependencies_met'] = False\\n\",\n",
       "   '\\n',\n",
       "   '        return metadata\\n',\n",
       "   '\\n',\n",
       "   '    def _forward_input(self, allow_stdin=False):\\n',\n",
       "   '        \"\"\"Forward raw_input and getpass to the current frontend.\\n',\n",
       "   '\\n',\n",
       "   '        via input_request\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        self._allow_stdin = allow_stdin\\n',\n",
       "   '\\n',\n",
       "   '        if PY3:\\n',\n",
       "   '            self._sys_raw_input = builtin_mod.input\\n',\n",
       "   '            builtin_mod.input = self.raw_input\\n',\n",
       "   '        else:\\n',\n",
       "   '            self._sys_raw_input = builtin_mod.raw_input\\n',\n",
       "   '            self._sys_eval_input = builtin_mod.input\\n',\n",
       "   '            builtin_mod.raw_input = self.raw_input\\n',\n",
       "   \"            builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))\\n\",\n",
       "   '        self._save_getpass = getpass.getpass\\n',\n",
       "   '        getpass.getpass = self.getpass\\n',\n",
       "   '\\n',\n",
       "   '    def _restore_input(self):\\n',\n",
       "   '        \"\"\"Restore raw_input, getpass\"\"\"\\n',\n",
       "   '        if PY3:\\n',\n",
       "   '            builtin_mod.input = self._sys_raw_input\\n',\n",
       "   '        else:\\n',\n",
       "   '            builtin_mod.raw_input = self._sys_raw_input\\n',\n",
       "   '            builtin_mod.input = self._sys_eval_input\\n',\n",
       "   '\\n',\n",
       "   '        getpass.getpass = self._save_getpass\\n',\n",
       "   '\\n',\n",
       "   '    @property\\n',\n",
       "   '    def execution_count(self):\\n',\n",
       "   '        return self.shell.execution_count\\n',\n",
       "   '\\n',\n",
       "   '    @execution_count.setter\\n',\n",
       "   '    def execution_count(self, value):\\n',\n",
       "   \"        # Ignore the incrememnting done by KernelBase, in favour of our shell's\\n\",\n",
       "   '        # execution counter.\\n',\n",
       "   '        pass\\n',\n",
       "   '\\n',\n",
       "   '    def do_execute(self, code, silent, store_history=True,\\n',\n",
       "   '                   user_expressions=None, allow_stdin=False):\\n',\n",
       "   \"        shell = self.shell # we'll need this a lot here\\n\",\n",
       "   '\\n',\n",
       "   '        self._forward_input(allow_stdin)\\n',\n",
       "   '\\n',\n",
       "   '        reply_content = {}\\n',\n",
       "   '        # FIXME: the shell calls the exception handler itself.\\n',\n",
       "   '        shell._reply_content = None\\n',\n",
       "   '        try:\\n',\n",
       "   '            shell.run_cell(code, store_history=store_history, silent=silent)\\n',\n",
       "   '        except:\\n',\n",
       "   \"            status = u'error'\\n\",\n",
       "   \"            # FIXME: this code right now isn't being used yet by default,\\n\",\n",
       "   '            # because the run_cell() call above directly fires off exception\\n',\n",
       "   '            # reporting.  This code, therefore, is only active in the scenario\\n',\n",
       "   '            # where runlines itself has an unhandled exception.  We need to\\n',\n",
       "   '            # uniformize this, for all exception construction to come from a\\n',\n",
       "   '            # single location in the codbase.\\n',\n",
       "   '            etype, evalue, tb = sys.exc_info()\\n',\n",
       "   '            tb_list = traceback.format_exception(etype, evalue, tb)\\n',\n",
       "   '            reply_content.update(shell._showtraceback(etype, evalue, tb_list))\\n',\n",
       "   '        else:\\n',\n",
       "   \"            status = u'ok'\\n\",\n",
       "   '        finally:\\n',\n",
       "   '            self._restore_input()\\n',\n",
       "   '\\n',\n",
       "   \"        reply_content[u'status'] = status\\n\",\n",
       "   '\\n',\n",
       "   '        # Return the execution counter so clients can display prompts\\n',\n",
       "   \"        reply_content['execution_count'] = shell.execution_count - 1\\n\",\n",
       "   '\\n',\n",
       "   '        # FIXME - fish exception info out of shell, possibly left there by\\n',\n",
       "   \"        # runlines.  We'll need to clean up this logic later.\\n\",\n",
       "   '        if shell._reply_content is not None:\\n',\n",
       "   '            reply_content.update(shell._reply_content)\\n',\n",
       "   '            # reset after use\\n',\n",
       "   '            shell._reply_content = None\\n',\n",
       "   '            # FIXME: deprecate piece for ipyparallel:\\n',\n",
       "   \"            e_info = dict(engine_uuid=self.ident, engine_id=self.int_id, method='execute')\\n\",\n",
       "   \"            reply_content['engine_info'] = e_info\\n\",\n",
       "   '\\n',\n",
       "   \"        if 'traceback' in reply_content:\\n\",\n",
       "   '            self.log.info(\"Exception in execute request:\\\\n%s\", \\'\\\\n\\'.join(reply_content[\\'traceback\\']))\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '        # At this point, we can tell whether the main code execution succeeded\\n',\n",
       "   '        # or not.  If it did, we proceed to evaluate user_expressions\\n',\n",
       "   \"        if reply_content['status'] == 'ok':\\n\",\n",
       "   \"            reply_content[u'user_expressions'] = \\\\\\n\",\n",
       "   '                         shell.user_expressions(user_expressions or {})\\n',\n",
       "   '        else:\\n',\n",
       "   \"            # If there was an error, don't even try to compute expressions\\n\",\n",
       "   \"            reply_content[u'user_expressions'] = {}\\n\",\n",
       "   '\\n',\n",
       "   '        # Payloads should be retrieved regardless of outcome, so we can both\\n',\n",
       "   '        # recover partial output (that could have been generated early in a\\n',\n",
       "   '        # block, before an error) and clear the payload system always.\\n',\n",
       "   \"        reply_content[u'payload'] = shell.payload_manager.read_payload()\\n\",\n",
       "   \"        # Be agressive about clearing the payload because we don't want\\n\",\n",
       "   '        # it to sit in memory until the next execute_request comes in.\\n',\n",
       "   '        shell.payload_manager.clear_payload()\\n',\n",
       "   '\\n',\n",
       "   '        return reply_content\\n',\n",
       "   '\\n',\n",
       "   '    def do_complete(self, code, cursor_pos):\\n',\n",
       "   '        # FIXME: IPython completers currently assume single line,\\n',\n",
       "   '        # but completion messages give multi-line context\\n',\n",
       "   '        # For now, extract line from cell, based on cursor_pos:\\n',\n",
       "   '        if cursor_pos is None:\\n',\n",
       "   '            cursor_pos = len(code)\\n',\n",
       "   '        line, offset = line_at_cursor(code, cursor_pos)\\n',\n",
       "   '        line_cursor = cursor_pos - offset\\n',\n",
       "   '\\n',\n",
       "   \"        txt, matches = self.shell.complete('', line, line_cursor)\\n\",\n",
       "   \"        return {'matches' : matches,\\n\",\n",
       "   \"                'cursor_end' : cursor_pos,\\n\",\n",
       "   \"                'cursor_start' : cursor_pos - len(txt),\\n\",\n",
       "   \"                'metadata' : {},\\n\",\n",
       "   \"                'status' : 'ok'}\\n\",\n",
       "   '\\n',\n",
       "   '    def do_inspect(self, code, cursor_pos, detail_level=0):\\n',\n",
       "   '        name = token_at_cursor(code, cursor_pos)\\n',\n",
       "   '        info = self.shell.object_inspect(name)\\n',\n",
       "   '\\n',\n",
       "   \"        reply_content = {'status' : 'ok'}\\n\",\n",
       "   \"        reply_content['data'] = data = {}\\n\",\n",
       "   \"        reply_content['metadata'] = {}\\n\",\n",
       "   \"        reply_content['found'] = info['found']\\n\",\n",
       "   \"        if info['found']:\\n\",\n",
       "   '            info_text = self.shell.object_inspect_text(\\n',\n",
       "   '                name,\\n',\n",
       "   '                detail_level=detail_level,\\n',\n",
       "   '            )\\n',\n",
       "   \"            data['text/plain'] = info_text\\n\",\n",
       "   '\\n',\n",
       "   '        return reply_content\\n',\n",
       "   '\\n',\n",
       "   '    def do_history(self, hist_access_type, output, raw, session=None, start=None,\\n',\n",
       "   '                   stop=None, n=None, pattern=None, unique=False):\\n',\n",
       "   \"        if hist_access_type == 'tail':\\n\",\n",
       "   '            hist = self.shell.history_manager.get_tail(n, raw=raw, output=output,\\n',\n",
       "   '                                                            include_latest=True)\\n',\n",
       "   '\\n',\n",
       "   \"        elif hist_access_type == 'range':\\n\",\n",
       "   '            hist = self.shell.history_manager.get_range(session, start, stop,\\n',\n",
       "   '                                                        raw=raw, output=output)\\n',\n",
       "   '\\n',\n",
       "   \"        elif hist_access_type == 'search':\\n\",\n",
       "   '            hist = self.shell.history_manager.search(\\n',\n",
       "   '                pattern, raw=raw, output=output, n=n, unique=unique)\\n',\n",
       "   '        else:\\n',\n",
       "   '            hist = []\\n',\n",
       "   '\\n',\n",
       "   \"        return {'history' : list(hist)}\\n\",\n",
       "   '\\n',\n",
       "   '    def do_shutdown(self, restart):\\n',\n",
       "   '        self.shell.exit_now = True\\n',\n",
       "   \"        return dict(status='ok', restart=restart)\\n\",\n",
       "   '\\n',\n",
       "   '    def do_is_complete(self, code):\\n',\n",
       "   '        status, indent_spaces = self.shell.input_transformer_manager.check_complete(code)\\n',\n",
       "   \"        r = {'status': status}\\n\",\n",
       "   \"        if status == 'incomplete':\\n\",\n",
       "   \"            r['indent'] = ' ' * indent_spaces\\n\",\n",
       "   '        return r\\n',\n",
       "   '\\n',\n",
       "   '    def do_apply(self, content, bufs, msg_id, reply_metadata):\\n',\n",
       "   '        from .serialize import serialize_object, unpack_apply_message\\n',\n",
       "   '        shell = self.shell\\n',\n",
       "   '        try:\\n',\n",
       "   '            working = shell.user_ns\\n',\n",
       "   '\\n',\n",
       "   '            prefix = \"_\"+str(msg_id).replace(\"-\",\"\")+\"_\"\\n',\n",
       "   '\\n',\n",
       "   '            f,args,kwargs = unpack_apply_message(bufs, working, copy=False)\\n',\n",
       "   '\\n',\n",
       "   \"            fname = getattr(f, '__name__', 'f')\\n\",\n",
       "   '\\n',\n",
       "   '            fname = prefix+\"f\"\\n',\n",
       "   '            argname = prefix+\"args\"\\n',\n",
       "   '            kwargname = prefix+\"kwargs\"\\n',\n",
       "   '            resultname = prefix+\"result\"\\n',\n",
       "   '\\n',\n",
       "   '            ns = { fname : f, argname : args, kwargname : kwargs , resultname : None }\\n',\n",
       "   '            # print ns\\n',\n",
       "   '            working.update(ns)\\n',\n",
       "   '            code = \"%s = %s(*%s,**%s)\" % (resultname, fname, argname, kwargname)\\n',\n",
       "   '            try:\\n',\n",
       "   '                exec(code, shell.user_global_ns, shell.user_ns)\\n',\n",
       "   '                result = working.get(resultname)\\n',\n",
       "   '            finally:\\n',\n",
       "   '                for key in ns:\\n',\n",
       "   '                    working.pop(key)\\n',\n",
       "   '\\n',\n",
       "   '            result_buf = serialize_object(result,\\n',\n",
       "   '                buffer_threshold=self.session.buffer_threshold,\\n',\n",
       "   '                item_threshold=self.session.item_threshold,\\n',\n",
       "   '            )\\n',\n",
       "   '\\n',\n",
       "   '        except:\\n',\n",
       "   '            # invoke IPython traceback formatting\\n',\n",
       "   '            shell.showtraceback()\\n',\n",
       "   '            # FIXME - fish exception info out of shell, possibly left there by\\n',\n",
       "   \"            # run_code.  We'll need to clean up this logic later.\\n\",\n",
       "   '            reply_content = {}\\n',\n",
       "   '            if shell._reply_content is not None:\\n',\n",
       "   '                reply_content.update(shell._reply_content)\\n',\n",
       "   '                # reset after use\\n',\n",
       "   '                shell._reply_content = None\\n',\n",
       "   '                \\n',\n",
       "   '                # FIXME: deprecate piece for ipyparallel:\\n',\n",
       "   \"                e_info = dict(engine_uuid=self.ident, engine_id=self.int_id, method='apply')\\n\",\n",
       "   \"                reply_content['engine_info'] = e_info\\n\",\n",
       "   '\\n',\n",
       "   \"            self.send_response(self.iopub_socket, u'error', reply_content,\\n\",\n",
       "   \"                                ident=self._topic('error'))\\n\",\n",
       "   '            self.log.info(\"Exception in apply request:\\\\n%s\", \\'\\\\n\\'.join(reply_content[\\'traceback\\']))\\n',\n",
       "   '            result_buf = []\\n',\n",
       "   '        else:\\n',\n",
       "   \"            reply_content = {'status' : 'ok'}\\n\",\n",
       "   '\\n',\n",
       "   '        return reply_content, result_buf\\n',\n",
       "   '\\n',\n",
       "   '    def do_clear(self):\\n',\n",
       "   '        self.shell.reset(False)\\n',\n",
       "   \"        return dict(status='ok')\\n\",\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '# This exists only for backwards compatibility - use IPythonKernel instead\\n',\n",
       "   '\\n',\n",
       "   'class Kernel(IPythonKernel):\\n',\n",
       "   '    def __init__(self, *args, **kwargs):\\n',\n",
       "   '        import warnings\\n',\n",
       "   \"        warnings.warn('Kernel is a deprecated alias of ipykernel.ipkernel.IPythonKernel',\\n\",\n",
       "   '                      DeprecationWarning)\\n',\n",
       "   '        super(Kernel, self).__init__(*args, **kwargs)\\n'],\n",
       "  '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/ipkernel.py'),\n",
       " {'apply_request': <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'comm_close': <bound method CommManager.comm_close of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "  'comm_info_request': <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'comm_msg': <bound method CommManager.comm_msg of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "  'comm_open': <bound method CommManager.comm_open of <ipykernel.comm.manager.CommManager object at 0x7f51c0147940>>,\n",
       "  'complete_request': <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'connect_request': <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'execute_request': <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'history_request': <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'inspect_request': <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'is_complete_request': <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'kernel_info_request': <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'shutdown_request': <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>},\n",
       " <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " {'abort_request': <bound method IPythonKernel.abort_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'apply_request': <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'clear_request': <bound method IPythonKernel.clear_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'comm_info_request': <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'complete_request': <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'connect_request': <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'execute_request': <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'history_request': <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'inspect_request': <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'is_complete_request': <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'kernel_info_request': <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "  'shutdown_request': <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>},\n",
       " <bound method IPythonKernel.complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.inspect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.history_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.comm_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.kernel_info_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.connect_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.shutdown_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.is_complete_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.apply_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.clear_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.abort_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       " {'Completer': <IPython.core.completer.IPCompleter at 0x7f51c0186080>,\n",
       "  'CustomTB': <bound method ZMQInteractiveShell.dummy_handler of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "  'InteractiveTB': <IPython.core.ultratb.AutoFormattedTB at 0x7f51c01130b8>,\n",
       "  'SyntaxTB': <IPython.core.ultratb.SyntaxTB at 0x7f51c721ae48>,\n",
       "  '_call_pdb': False,\n",
       "  '_cross_validation_lock': False,\n",
       "  '_last_input_line': 'gc.get_objects()',\n",
       "  '_main_mod_cache': {},\n",
       "  '_orig_sys_module_state': {'excepthook': <bound method IPKernelApp.excepthook of <ipykernel.kernelapp.IPKernelApp object at 0x7f51d2a1ac18>>,\n",
       "   'stderr': <ipykernel.iostream.OutStream at 0x7f51c1221b38>,\n",
       "   'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>,\n",
       "   'stdout': <ipykernel.iostream.OutStream at 0x7f51c1221b70>},\n",
       "  '_orig_sys_modules_main_mod': <module 'ipykernel.__main__' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__main__.py'>,\n",
       "  '_orig_sys_modules_main_name': '__main__',\n",
       "  '_reply_content': None,\n",
       "  '_showtraceback': <bound method ZMQInteractiveShell._showtraceback of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       "   'ipython_dir': {'change': [<traitlets.traitlets._CallbackWrapper at 0x7f51c01478d0>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'_post_execute': {},\n",
       "   'alias_manager': <IPython.core.alias.AliasManager at 0x7f51c01137b8>,\n",
       "   'ast_node_interactivity': 'last_expr',\n",
       "   'ast_transformers': [],\n",
       "   'autocall': 0,\n",
       "   'autoindent': False,\n",
       "   'automagic': True,\n",
       "   'banner1': 'Python 3.4.3 (default, Jun 29 2015, 12:16:01) \\nType \"copyright\", \"credits\" or \"license\" for more information.\\n\\nIPython 4.1.2 -- An enhanced Interactive Python.\\n?         -> Introduction and overview of IPython\\'s features.\\n%quickref -> Quick reference.\\nhelp      -> Python\\'s own help system.\\nobject?   -> Details about \\'object\\', use \\'object??\\' for extra details.\\n',\n",
       "   'banner2': '',\n",
       "   'builtin_trap': <IPython.core.builtin_trap.BuiltinTrap at 0x7f51c016eef0>,\n",
       "   'cache_size': 1000,\n",
       "   'color_info': True,\n",
       "   'colors': 'Linux',\n",
       "   'colors_force': True,\n",
       "   'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'data_pub_class': ipykernel.datapub.ZMQDataPublisher,\n",
       "   'debug': False,\n",
       "   'deep_reload': False,\n",
       "   'disable_failing_post_execute': False,\n",
       "   'display_formatter': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   'display_page': False,\n",
       "   'display_pub_class': ipykernel.zmqshell.ZMQDisplayPublisher,\n",
       "   'display_trap': <IPython.core.display_trap.DisplayTrap at 0x7f51c0113320>,\n",
       "   'displayhook_class': ipykernel.displayhook.ZMQShellDisplayHook,\n",
       "   'execution_count': 21,\n",
       "   'exit_now': False,\n",
       "   'exiter': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'extension_manager': <IPython.core.extensions.ExtensionManager at 0x7f51c0113eb8>,\n",
       "   'filename': '<ipython console>',\n",
       "   'history_length': 10000,\n",
       "   'history_load_length': 1000,\n",
       "   'history_manager': <IPython.core.history.HistoryManager at 0x7f51c1221710>,\n",
       "   'input_transformer_manager': <IPython.core.inputsplitter.IPythonInputSplitter at 0x7f51c00d4be0>,\n",
       "   'ipython_dir': '/home/pasha/.ipython',\n",
       "   'kernel': <ipykernel.ipkernel.IPythonKernel at 0x7f51c1221278>,\n",
       "   'logappend': '',\n",
       "   'logfile': '',\n",
       "   'logstart': False,\n",
       "   'magics_manager': <IPython.core.magic.MagicsManager at 0x7f51c0113470>,\n",
       "   'multiline_history': True,\n",
       "   'object_info_string_level': 0,\n",
       "   'parent': <ipykernel.ipkernel.IPythonKernel at 0x7f51c1221278>,\n",
       "   'parent_header': {'buffers': [],\n",
       "    'content': {'allow_stdin': True,\n",
       "     'code': 'gc.get_objects()',\n",
       "     'silent': False,\n",
       "     'stop_on_error': True,\n",
       "     'store_history': True,\n",
       "     'user_expressions': {}},\n",
       "    'header': {'date': '2016-03-20T19:46:05.318327',\n",
       "     'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "     'msg_type': 'execute_request',\n",
       "     'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "     'username': 'username',\n",
       "     'version': '5.0'},\n",
       "    'metadata': {},\n",
       "    'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "    'msg_type': 'execute_request',\n",
       "    'parent_header': {}},\n",
       "   'payload_manager': <IPython.core.payload.PayloadManager at 0x7f51c01476a0>,\n",
       "   'pdb': False,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'profile_dir': <IPython.core.profiledir.ProfileDir at 0x7f51c1221518>,\n",
       "   'prompt_in1': 'In [\\\\#]: ',\n",
       "   'prompt_in2': '   .\\\\D.: ',\n",
       "   'prompt_out': 'Out[\\\\#]: ',\n",
       "   'prompts_pad_left': True,\n",
       "   'quiet': False,\n",
       "   'readline_delims': '',\n",
       "   'readline_remove_delims': '-/~',\n",
       "   'readline_use': False,\n",
       "   'separate_in': '\\n',\n",
       "   'separate_out': '',\n",
       "   'separate_out2': '',\n",
       "   'show_rewritten_input': True,\n",
       "   'wildcards_case_sensitive': True,\n",
       "   'xmode': 'Context'},\n",
       "  'compile': <IPython.core.compilerop.CachingCompiler at 0x7f51c124b748>,\n",
       "  'configurables': [<ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "   <IPython.core.history.HistoryManager at 0x7f51c1221710>,\n",
       "   <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   <IPython.core.completer.IPCompleter at 0x7f51c0186080>,\n",
       "   <IPython.core.prompts.PromptManager at 0x7f51c01131d0>,\n",
       "   <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "   <ipykernel.zmqshell.ZMQDisplayPublisher at 0x7f51c0113438>,\n",
       "   <ipykernel.displayhook.ZMQShellDisplayHook at 0x7f51c0113278>,\n",
       "   <IPython.core.magics.UserMagics at 0x7f51c01134a8>,\n",
       "   <IPython.core.magic.MagicsManager at 0x7f51c0113470>,\n",
       "   <IPython.core.magics.auto.AutoMagics at 0x7f51c0113a90>,\n",
       "   <IPython.core.magics.basic.BasicMagics at 0x7f51c0113b00>,\n",
       "   <IPython.core.magics.code.CodeMagics at 0x7f51c0113b38>,\n",
       "   <IPython.core.magics.config.ConfigMagics at 0x7f51c0113b70>,\n",
       "   <IPython.core.magics.deprecated.DeprecatedMagics at 0x7f51c0113ba8>,\n",
       "   <IPython.core.magics.display.DisplayMagics at 0x7f51c0113be0>,\n",
       "   <IPython.core.magics.execution.ExecutionMagics at 0x7f51c0113c18>,\n",
       "   <IPython.core.magics.extension.ExtensionMagics at 0x7f51c0113c50>,\n",
       "   <IPython.core.magics.history.HistoryMagics at 0x7f51c0113c88>,\n",
       "   <IPython.core.magics.logging.LoggingMagics at 0x7f51c0113cc0>,\n",
       "   <IPython.core.magics.namespace.NamespaceMagics at 0x7f51c0113cf8>,\n",
       "   <IPython.core.magics.osm.OSMagics at 0x7f51c0113d30>,\n",
       "   <IPython.core.magics.pylab.PylabMagics at 0x7f51c0113d68>,\n",
       "   <IPython.core.magics.script.ScriptMagics at 0x7f51c0113da0>,\n",
       "   <ipykernel.zmqshell.KernelMagics at 0x7f51c013b358>,\n",
       "   <IPython.core.alias.AliasManager at 0x7f51c01137b8>,\n",
       "   <IPython.core.extensions.ExtensionManager at 0x7f51c0113eb8>,\n",
       "   <IPython.core.payload.PayloadManager at 0x7f51c01476a0>,\n",
       "   <ipykernel.comm.manager.CommManager at 0x7f51c0147940>,\n",
       "   <ipykernel.kernelapp.IPKernelApp at 0x7f51d2a1ac18>,\n",
       "   <storemagic.StoreMagics at 0x7f51c01477b8>,\n",
       "   <storemagic.StoreMagics at 0x7f51c01477b8>],\n",
       "  'custom_exceptions': (),\n",
       "  'db': PickleShareDB('/home/pasha/.ipython/profile_default/db'),\n",
       "  'define_magic': <bound method MagicsManager.define_magic of <IPython.core.magic.MagicsManager object at 0x7f51c0113470>>,\n",
       "  'dir_stack': [],\n",
       "  'display_pub': <ipykernel.zmqshell.ZMQDisplayPublisher at 0x7f51c0113438>,\n",
       "  'displayhook': <ipykernel.displayhook.ZMQShellDisplayHook at 0x7f51c0113278>,\n",
       "  'events': <IPython.core.events.EventManager at 0x7f51c016ecc0>,\n",
       "  'has_readline': False,\n",
       "  'home_dir': '/home/pasha',\n",
       "  'hooks': {'clipboard_get': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eeb8>,\n",
       "   'editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ecf8>,\n",
       "   'fix_error_editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed30>,\n",
       "   'late_startup_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016edd8>,\n",
       "   'pre_prompt_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee48>,\n",
       "   'pre_run_code_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee80>,\n",
       "   'show_in_pager': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee10>,\n",
       "   'shutdown_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eda0>,\n",
       "   'synchronize_with_editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed68>},\n",
       "  'indent_current_nsp': 0,\n",
       "  'inspector': <IPython.core.oinspect.Inspector at 0x7f51c016ef60>,\n",
       "  'logger': <IPython.core.logger.Logger at 0x7f51c016ef28>,\n",
       "  'meta': {},\n",
       "  'more': False,\n",
       "  'ns_table': {'builtin': {'ArithmeticError': ArithmeticError,\n",
       "    'AssertionError': AssertionError,\n",
       "    'AttributeError': AttributeError,\n",
       "    'BaseException': BaseException,\n",
       "    'BlockingIOError': BlockingIOError,\n",
       "    'BrokenPipeError': BrokenPipeError,\n",
       "    'BufferError': BufferError,\n",
       "    'BytesWarning': BytesWarning,\n",
       "    'ChildProcessError': ChildProcessError,\n",
       "    'ConnectionAbortedError': ConnectionAbortedError,\n",
       "    'ConnectionError': ConnectionError,\n",
       "    'ConnectionRefusedError': ConnectionRefusedError,\n",
       "    'ConnectionResetError': ConnectionResetError,\n",
       "    'DeprecationWarning': DeprecationWarning,\n",
       "    'EOFError': EOFError,\n",
       "    'Ellipsis': Ellipsis,\n",
       "    'EnvironmentError': OSError,\n",
       "    'Exception': Exception,\n",
       "    'False': False,\n",
       "    'FileExistsError': FileExistsError,\n",
       "    'FileNotFoundError': FileNotFoundError,\n",
       "    'FloatingPointError': FloatingPointError,\n",
       "    'FutureWarning': FutureWarning,\n",
       "    'GeneratorExit': GeneratorExit,\n",
       "    'IOError': OSError,\n",
       "    'ImportError': ImportError,\n",
       "    'ImportWarning': ImportWarning,\n",
       "    'IndentationError': IndentationError,\n",
       "    'IndexError': IndexError,\n",
       "    'InterruptedError': InterruptedError,\n",
       "    'IsADirectoryError': IsADirectoryError,\n",
       "    'KeyError': KeyError,\n",
       "    'KeyboardInterrupt': KeyboardInterrupt,\n",
       "    'LookupError': LookupError,\n",
       "    'MemoryError': MemoryError,\n",
       "    'NameError': NameError,\n",
       "    'None': None,\n",
       "    'NotADirectoryError': NotADirectoryError,\n",
       "    'NotImplemented': NotImplemented,\n",
       "    'NotImplementedError': NotImplementedError,\n",
       "    'OSError': OSError,\n",
       "    'OverflowError': OverflowError,\n",
       "    'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "    'PermissionError': PermissionError,\n",
       "    'ProcessLookupError': ProcessLookupError,\n",
       "    'ReferenceError': ReferenceError,\n",
       "    'ResourceWarning': ResourceWarning,\n",
       "    'RuntimeError': RuntimeError,\n",
       "    'RuntimeWarning': RuntimeWarning,\n",
       "    'StopIteration': StopIteration,\n",
       "    'SyntaxError': SyntaxError,\n",
       "    'SyntaxWarning': SyntaxWarning,\n",
       "    'SystemError': SystemError,\n",
       "    'SystemExit': SystemExit,\n",
       "    'TabError': TabError,\n",
       "    'TimeoutError': TimeoutError,\n",
       "    'True': True,\n",
       "    'TypeError': TypeError,\n",
       "    'UnboundLocalError': UnboundLocalError,\n",
       "    'UnicodeDecodeError': UnicodeDecodeError,\n",
       "    'UnicodeEncodeError': UnicodeEncodeError,\n",
       "    'UnicodeError': UnicodeError,\n",
       "    'UnicodeTranslateError': UnicodeTranslateError,\n",
       "    'UnicodeWarning': UnicodeWarning,\n",
       "    'UserWarning': UserWarning,\n",
       "    'ValueError': ValueError,\n",
       "    'Warning': Warning,\n",
       "    'ZeroDivisionError': ZeroDivisionError,\n",
       "    '__IPYTHON__': True,\n",
       "    '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "    '__build_class__': <function __build_class__>,\n",
       "    '__debug__': True,\n",
       "    '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "    '__import__': <function __import__>,\n",
       "    '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "    '__name__': 'builtins',\n",
       "    '__package__': '',\n",
       "    '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "    'abs': <function abs>,\n",
       "    'all': <function all>,\n",
       "    'any': <function any>,\n",
       "    'ascii': <function ascii>,\n",
       "    'bin': <function bin>,\n",
       "    'bool': bool,\n",
       "    'bytearray': bytearray,\n",
       "    'bytes': bytes,\n",
       "    'callable': <function callable>,\n",
       "    'chr': <function chr>,\n",
       "    'classmethod': classmethod,\n",
       "    'compile': <function compile>,\n",
       "    'complex': complex,\n",
       "    'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "    All Rights Reserved.\n",
       "    \n",
       "    Copyright (c) 2000 BeOpen.com.\n",
       "    All Rights Reserved.\n",
       "    \n",
       "    Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "    All Rights Reserved.\n",
       "    \n",
       "    Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "    All Rights Reserved.,\n",
       "    'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "        for supporting Python development.  See www.python.org for more information.,\n",
       "    'delattr': <function delattr>,\n",
       "    'dict': dict,\n",
       "    'dir': <function dir>,\n",
       "    'divmod': <function divmod>,\n",
       "    'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "    'enumerate': enumerate,\n",
       "    'eval': <function eval>,\n",
       "    'exec': <function exec>,\n",
       "    'filter': filter,\n",
       "    'float': float,\n",
       "    'format': <function format>,\n",
       "    'frozenset': frozenset,\n",
       "    'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "    'getattr': <function getattr>,\n",
       "    'globals': <function globals>,\n",
       "    'hasattr': <function hasattr>,\n",
       "    'hash': <function hash>,\n",
       "    'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "    'hex': <function hex>,\n",
       "    'id': <function id>,\n",
       "    'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "    'int': int,\n",
       "    'isinstance': <function isinstance>,\n",
       "    'issubclass': <function issubclass>,\n",
       "    'iter': <function iter>,\n",
       "    'len': <function len>,\n",
       "    'license': See https://www.python.org/psf/license/,\n",
       "    'list': list,\n",
       "    'locals': <function locals>,\n",
       "    'map': map,\n",
       "    'max': <function max>,\n",
       "    'memoryview': memoryview,\n",
       "    'min': <function min>,\n",
       "    'next': <function next>,\n",
       "    'object': object,\n",
       "    'oct': <function oct>,\n",
       "    'open': <function io.open>,\n",
       "    'ord': <function ord>,\n",
       "    'pow': <function pow>,\n",
       "    'print': <function print>,\n",
       "    'property': property,\n",
       "    'range': range,\n",
       "    'repr': <function repr>,\n",
       "    'reversed': reversed,\n",
       "    'round': <function round>,\n",
       "    'set': set,\n",
       "    'setattr': <function setattr>,\n",
       "    'slice': slice,\n",
       "    'sorted': <function sorted>,\n",
       "    'staticmethod': staticmethod,\n",
       "    'str': str,\n",
       "    'sum': <function sum>,\n",
       "    'super': super,\n",
       "    'tuple': tuple,\n",
       "    'type': type,\n",
       "    'vars': <function vars>,\n",
       "    'zip': zip},\n",
       "   'user_global': {'In': ['',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "     \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "     'pick([1, 2, 3], 2)',\n",
       "     \"pick([1, 2, 3], '2')\",\n",
       "     'import gc',\n",
       "     'import gc\\nпс',\n",
       "     'import gc\\ngc',\n",
       "     'import gc\\ngc.garbage',\n",
       "     'gc.get_objects()'],\n",
       "    'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "    '_': [],\n",
       "    '_14': 3,\n",
       "    '_15': 3,\n",
       "    '_19': <module 'gc' (built-in)>,\n",
       "    '_20': [],\n",
       "    '__': <module 'gc' (built-in)>,\n",
       "    '___': 3,\n",
       "    '__builtin__': <module 'builtins' (built-in)>,\n",
       "    '__builtins__': <module 'builtins' (built-in)>,\n",
       "    '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "    '__loader__': None,\n",
       "    '__name__': '__main__',\n",
       "    '__package__': None,\n",
       "    '__spec__': None,\n",
       "    '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "    '_i': 'import gc\\ngc.garbage',\n",
       "    '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    '_i15': 'pick([1, 2, 3], 2)',\n",
       "    '_i16': \"pick([1, 2, 3], '2')\",\n",
       "    '_i17': 'import gc',\n",
       "    '_i18': 'import gc\\nпс',\n",
       "    '_i19': 'import gc\\ngc',\n",
       "    '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    '_i20': 'import gc\\ngc.garbage',\n",
       "    '_i21': 'gc.get_objects()',\n",
       "    '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_ih': ['',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "     \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "     'pick([1, 2, 3], 2)',\n",
       "     \"pick([1, 2, 3], '2')\",\n",
       "     'import gc',\n",
       "     'import gc\\nпс',\n",
       "     'import gc\\ngc',\n",
       "     'import gc\\ngc.garbage',\n",
       "     'gc.get_objects()'],\n",
       "    '_ii': 'import gc\\ngc',\n",
       "    '_iii': 'import gc\\nпс',\n",
       "    '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "    '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "    'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "    'gc': <module 'gc' (built-in)>,\n",
       "    'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "    'pick': <function __main__.pick>,\n",
       "    'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "    'v': 3,\n",
       "    'x': {1: False, 3: True}},\n",
       "   'user_local': {'In': ['',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "     \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "     'pick([1, 2, 3], 2)',\n",
       "     \"pick([1, 2, 3], '2')\",\n",
       "     'import gc',\n",
       "     'import gc\\nпс',\n",
       "     'import gc\\ngc',\n",
       "     'import gc\\ngc.garbage',\n",
       "     'gc.get_objects()'],\n",
       "    'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "    '_': [],\n",
       "    '_14': 3,\n",
       "    '_15': 3,\n",
       "    '_19': <module 'gc' (built-in)>,\n",
       "    '_20': [],\n",
       "    '__': <module 'gc' (built-in)>,\n",
       "    '___': 3,\n",
       "    '__builtin__': <module 'builtins' (built-in)>,\n",
       "    '__builtins__': <module 'builtins' (built-in)>,\n",
       "    '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "    '__loader__': None,\n",
       "    '__name__': '__main__',\n",
       "    '__package__': None,\n",
       "    '__spec__': None,\n",
       "    '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "    '_i': 'import gc\\ngc.garbage',\n",
       "    '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    '_i15': 'pick([1, 2, 3], 2)',\n",
       "    '_i16': \"pick([1, 2, 3], '2')\",\n",
       "    '_i17': 'import gc',\n",
       "    '_i18': 'import gc\\nпс',\n",
       "    '_i19': 'import gc\\ngc',\n",
       "    '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    '_i20': 'import gc\\ngc.garbage',\n",
       "    '_i21': 'gc.get_objects()',\n",
       "    '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    '_ih': ['',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "     'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "     \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "     \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "     'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "     'pick([1, 2, 3], 2)',\n",
       "     \"pick([1, 2, 3], '2')\",\n",
       "     'import gc',\n",
       "     'import gc\\nпс',\n",
       "     'import gc\\ngc',\n",
       "     'import gc\\ngc.garbage',\n",
       "     'gc.get_objects()'],\n",
       "    '_ii': 'import gc\\ngc',\n",
       "    '_iii': 'import gc\\nпс',\n",
       "    '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "    '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "    'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "    'gc': <module 'gc' (built-in)>,\n",
       "    'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "    'pick': <function __main__.pick>,\n",
       "    'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "    'v': 3,\n",
       "    'x': {1: False, 3: True}}},\n",
       "  'prefilter': <bound method PrefilterManager.prefilter_lines of <IPython.core.prefilter.PrefilterManager object at 0x7f51c016e908>>,\n",
       "  'prompt_manager': <IPython.core.prompts.PromptManager at 0x7f51c01131d0>,\n",
       "  'pycolorize': <function IPython.core.interactiveshell.InteractiveShell.init_syntax_highlighting.<locals>.<lambda>>,\n",
       "  'raw_input_original': <function input>,\n",
       "  'readline': None,\n",
       "  'readline_no_record': <IPython.utils.contexts.NoOpContext at 0x7f51c0186048>,\n",
       "  'register_magics': <bound method MagicsManager.register of <IPython.core.magic.MagicsManager object at 0x7f51c0113470>>,\n",
       "  'set_custom_completer': <function IPython.core.interactiveshell.no_op>,\n",
       "  'set_readline_completer': <function IPython.core.interactiveshell.no_op>,\n",
       "  'starting_dir': '/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle',\n",
       "  'stdin_encoding': 'UTF-8',\n",
       "  'strdispatchers': {'complete_command': <Strdispatch {'%run': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186fd0>, 'from': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e80>, '%reset': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c01863c8>, '%aimport': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186f28>, 'import': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e48>, '%cd': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186358>}, {}>},\n",
       "  'sys_excepthook': <bound method IPKernelApp.excepthook of <ipykernel.kernelapp.IPKernelApp object at 0x7f51d2a1ac18>>,\n",
       "  'tempdirs': [],\n",
       "  'tempfiles': [],\n",
       "  'user_module': <module '__main__'>,\n",
       "  'user_ns': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}},\n",
       "  'user_ns_hidden': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       "  'ipython_dir': {'change': [<traitlets.traitlets._CallbackWrapper at 0x7f51c01478d0>]}},\n",
       " (18642,\n",
       "  1457880526.353978,\n",
       "  ['\"\"\"A ZMQ-based subclass of InteractiveShell.\\n',\n",
       "   '\\n',\n",
       "   'This code is meant to ease the refactoring of the base InteractiveShell into\\n',\n",
       "   'something with a cleaner architecture for 2-process use, without actually\\n',\n",
       "   \"breaking InteractiveShell itself.  So we're doing something a bit ugly, where\\n\",\n",
       "   'we subclass and override what we want to fix.  Once this is working well, we\\n',\n",
       "   'can go back to the base class and refactor the code for a cleaner inheritance\\n',\n",
       "   \"implementation that doesn't rely on so much monkeypatching.\\n\",\n",
       "   '\\n',\n",
       "   'But this lets us maintain a fully working IPython as we develop the new\\n',\n",
       "   'machinery.  This should thus be thought of as scaffolding.\\n',\n",
       "   '\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '# Copyright (c) IPython Development Team.\\n',\n",
       "   '# Distributed under the terms of the Modified BSD License.\\n',\n",
       "   '\\n',\n",
       "   'from __future__ import print_function\\n',\n",
       "   '\\n',\n",
       "   'import os\\n',\n",
       "   'import sys\\n',\n",
       "   'import time\\n',\n",
       "   'import warnings\\n',\n",
       "   '\\n',\n",
       "   'from zmq.eventloop import ioloop\\n',\n",
       "   '\\n',\n",
       "   'from IPython.core.interactiveshell import (\\n',\n",
       "   '    InteractiveShell, InteractiveShellABC\\n',\n",
       "   ')\\n',\n",
       "   'from IPython.core import page\\n',\n",
       "   'from IPython.core.autocall import ZMQExitAutocall\\n',\n",
       "   'from IPython.core.displaypub import DisplayPublisher\\n',\n",
       "   'from IPython.core.error import UsageError\\n',\n",
       "   'from IPython.core.magics import MacroToEdit, CodeMagics\\n',\n",
       "   'from IPython.core.magic import magics_class, line_magic, Magics\\n',\n",
       "   'from IPython.core import payloadpage\\n',\n",
       "   'from IPython.core.usage import default_banner\\n',\n",
       "   'from IPython.display import display, Javascript\\n',\n",
       "   'from ipykernel import (\\n',\n",
       "   '    get_connection_file, get_connection_info, connect_qtconsole\\n',\n",
       "   ')\\n',\n",
       "   'from IPython.utils import openpy\\n',\n",
       "   'from ipykernel.jsonutil import json_clean, encode_images\\n',\n",
       "   'from IPython.utils.process import arg_split\\n',\n",
       "   'from ipython_genutils import py3compat\\n',\n",
       "   'from ipython_genutils.py3compat import unicode_type\\n',\n",
       "   'from traitlets import Instance, Type, Dict, CBool, CBytes, Any\\n',\n",
       "   'from IPython.utils.warn import error\\n',\n",
       "   'from ipykernel.displayhook import ZMQShellDisplayHook\\n',\n",
       "   'from jupyter_client.session import extract_header\\n',\n",
       "   'from jupyter_client.session import Session\\n',\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '# Functions and classes\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   'class ZMQDisplayPublisher(DisplayPublisher):\\n',\n",
       "   '    \"\"\"A display publisher that publishes data using a ZeroMQ PUB socket.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    session = Instance(Session, allow_none=True)\\n',\n",
       "   '    pub_socket = Any(allow_none=True)\\n',\n",
       "   '    parent_header = Dict({})\\n',\n",
       "   \"    topic = CBytes(b'display_data')\\n\",\n",
       "   '\\n',\n",
       "   '    def set_parent(self, parent):\\n',\n",
       "   '        \"\"\"Set the parent for outbound messages.\"\"\"\\n',\n",
       "   '        self.parent_header = extract_header(parent)\\n',\n",
       "   '\\n',\n",
       "   '    def _flush_streams(self):\\n',\n",
       "   '        \"\"\"flush IO Streams prior to display\"\"\"\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   '\\n',\n",
       "   '    def publish(self, data, metadata=None, source=None):\\n',\n",
       "   '        self._flush_streams()\\n',\n",
       "   '        if metadata is None:\\n',\n",
       "   '            metadata = {}\\n',\n",
       "   '        self._validate_data(data, metadata)\\n',\n",
       "   '        content = {}\\n',\n",
       "   \"        content['data'] = encode_images(data)\\n\",\n",
       "   \"        content['metadata'] = metadata\\n\",\n",
       "   '        self.session.send(\\n',\n",
       "   \"            self.pub_socket, u'display_data', json_clean(content),\\n\",\n",
       "   '            parent=self.parent_header, ident=self.topic,\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '    def clear_output(self, wait=False):\\n',\n",
       "   '        content = dict(wait=wait)\\n',\n",
       "   '        self._flush_streams()\\n',\n",
       "   '        self.session.send(\\n',\n",
       "   \"            self.pub_socket, u'clear_output', content,\\n\",\n",
       "   '            parent=self.parent_header, ident=self.topic,\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '@magics_class\\n',\n",
       "   'class KernelMagics(Magics):\\n',\n",
       "   '    #------------------------------------------------------------------------\\n',\n",
       "   '    # Magic overrides\\n',\n",
       "   '    #------------------------------------------------------------------------\\n',\n",
       "   '    # Once the base class stops inheriting from magic, this code needs to be\\n',\n",
       "   '    # moved into a separate machinery as well.  For now, at least isolate here\\n',\n",
       "   '    # the magics which this class needs to implement differently from the base\\n',\n",
       "   '    # class, or that are unique to it.\\n',\n",
       "   '\\n',\n",
       "   '    _find_edit_target = CodeMagics._find_edit_target\\n',\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   \"    def edit(self, parameter_s='', last_call=['','']):\\n\",\n",
       "   '        \"\"\"Bring up an editor and execute the resulting code.\\n',\n",
       "   '\\n',\n",
       "   '        Usage:\\n',\n",
       "   '          %edit [options] [args]\\n',\n",
       "   '\\n',\n",
       "   '        %edit runs an external text editor. You will need to set the command for\\n',\n",
       "   '        this editor via the ``TerminalInteractiveShell.editor`` option in your\\n',\n",
       "   '        configuration file before it will work.\\n',\n",
       "   '\\n',\n",
       "   '        This command allows you to conveniently edit multi-line code right in\\n',\n",
       "   '        your IPython session.\\n',\n",
       "   '\\n',\n",
       "   '        If called without arguments, %edit opens up an empty editor with a\\n',\n",
       "   '        temporary file and will execute the contents of this file when you\\n',\n",
       "   \"        close it (don't forget to save it!).\\n\",\n",
       "   '\\n',\n",
       "   '        Options:\\n',\n",
       "   '\\n',\n",
       "   '        -n <number>\\n',\n",
       "   '          Open the editor at a specified line number. By default, the IPython\\n',\n",
       "   \"          editor hook uses the unix syntax 'editor +N filename', but you can\\n\",\n",
       "   '          configure this by providing your own modified hook if your favorite\\n',\n",
       "   '          editor supports line-number specifications with a different syntax.\\n',\n",
       "   '\\n',\n",
       "   '        -p\\n',\n",
       "   '          Call the editor with the same data as the previous time it was used,\\n',\n",
       "   '          regardless of how long ago (in your current session) it was.\\n',\n",
       "   '\\n',\n",
       "   '        -r\\n',\n",
       "   \"          Use 'raw' input. This option only applies to input taken from the\\n\",\n",
       "   \"          user's history.  By default, the 'processed' history is used, so that\\n\",\n",
       "   '          magics are loaded in their transformed version to valid Python.  If\\n',\n",
       "   '          this option is given, the raw input as typed as the command line is\\n',\n",
       "   '          used instead.  When you exit the editor, it will be executed by\\n',\n",
       "   \"          IPython's own processor.\\n\",\n",
       "   '\\n',\n",
       "   '        Arguments:\\n',\n",
       "   '\\n',\n",
       "   '        If arguments are given, the following possibilites exist:\\n',\n",
       "   '\\n',\n",
       "   '        - The arguments are numbers or pairs of colon-separated numbers (like\\n',\n",
       "   '          1 4:8 9). These are interpreted as lines of previous input to be\\n',\n",
       "   '          loaded into the editor. The syntax is the same of the %macro command.\\n',\n",
       "   '\\n',\n",
       "   \"        - If the argument doesn't start with a number, it is evaluated as a\\n\",\n",
       "   '          variable and its contents loaded into the editor. You can thus edit\\n',\n",
       "   '          any string which contains python code (including the result of\\n',\n",
       "   '          previous edits).\\n',\n",
       "   '\\n',\n",
       "   '        - If the argument is the name of an object (other than a string),\\n',\n",
       "   '          IPython will try to locate the file where it was defined and open the\\n',\n",
       "   '          editor at the point where it is defined. You can use ``%edit function``\\n',\n",
       "   \"          to load an editor exactly at the point where 'function' is defined,\\n\",\n",
       "   '          edit it and have the file be executed automatically.\\n',\n",
       "   '\\n',\n",
       "   '          If the object is a macro (see %macro for details), this opens up your\\n',\n",
       "   \"          specified editor with a temporary file containing the macro's data.\\n\",\n",
       "   '          Upon exit, the macro is reloaded with the contents of the file.\\n',\n",
       "   '\\n',\n",
       "   '          Note: opening at an exact line is only supported under Unix, and some\\n',\n",
       "   '          editors (like kedit and gedit up to Gnome 2.8) do not understand the\\n',\n",
       "   \"          '+NUMBER' parameter necessary for this feature. Good editors like\\n\",\n",
       "   '          (X)Emacs, vi, jed, pico and joe all do.\\n',\n",
       "   '\\n',\n",
       "   '        - If the argument is not found as a variable, IPython will look for a\\n',\n",
       "   '          file with that name (adding .py if necessary) and load it into the\\n',\n",
       "   '          editor. It will execute its contents with execfile() when you exit,\\n',\n",
       "   '          loading any code in the file into your interactive namespace.\\n',\n",
       "   '\\n',\n",
       "   '        Unlike in the terminal, this is designed to use a GUI editor, and we do\\n',\n",
       "   '        not know when it has closed. So the file you edit will not be\\n',\n",
       "   '        automatically executed or printed.\\n',\n",
       "   '\\n',\n",
       "   '        Note that %edit is also available through the alias %ed.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '\\n',\n",
       "   \"        opts,args = self.parse_options(parameter_s,'prn:')\\n\",\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   '            filename, lineno, _ = CodeMagics._find_edit_target(self.shell, args, opts, last_call)\\n',\n",
       "   '        except MacroToEdit as e:\\n',\n",
       "   '            # TODO: Implement macro editing over 2 processes.\\n',\n",
       "   '            print(\"Macro editing not yet implemented in 2-process model.\")\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        # Make sure we send to the client an absolute path, in case the working\\n',\n",
       "   \"        # directory of client and kernel don't match\\n\",\n",
       "   '        filename = os.path.abspath(filename)\\n',\n",
       "   '\\n',\n",
       "   '        payload = {\\n',\n",
       "   \"            'source' : 'edit_magic',\\n\",\n",
       "   \"            'filename' : filename,\\n\",\n",
       "   \"            'line_number' : lineno\\n\",\n",
       "   '        }\\n',\n",
       "   '        self.shell.payload_manager.write_payload(payload)\\n',\n",
       "   '\\n',\n",
       "   '    # A few magics that are adapted to the specifics of using pexpect and a\\n',\n",
       "   '    # remote terminal\\n',\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   '    def clear(self, arg_s):\\n',\n",
       "   '        \"\"\"Clear the terminal.\"\"\"\\n',\n",
       "   \"        if os.name == 'posix':\\n\",\n",
       "   '            self.shell.system(\"clear\")\\n',\n",
       "   '        else:\\n',\n",
       "   '            self.shell.system(\"cls\")\\n',\n",
       "   '\\n',\n",
       "   \"    if os.name == 'nt':\\n\",\n",
       "   '        # This is the usual name in windows\\n',\n",
       "   \"        cls = line_magic('cls')(clear)\\n\",\n",
       "   '\\n',\n",
       "   \"    # Terminal pagers won't work over pexpect, but we do have our own pager\\n\",\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   '    def less(self, arg_s):\\n',\n",
       "   '        \"\"\"Show a file through the pager.\\n',\n",
       "   '\\n',\n",
       "   '        Files ending in .py are syntax-highlighted.\"\"\"\\n',\n",
       "   '        if not arg_s:\\n',\n",
       "   \"            raise UsageError('Missing filename.')\\n\",\n",
       "   '\\n',\n",
       "   \"        if arg_s.endswith('.py'):\\n\",\n",
       "   '            cont = self.shell.pycolorize(openpy.read_py_file(arg_s, skip_encoding_cookie=False))\\n',\n",
       "   '        else:\\n',\n",
       "   '            cont = open(arg_s).read()\\n',\n",
       "   '        page.page(cont)\\n',\n",
       "   '\\n',\n",
       "   \"    more = line_magic('more')(less)\\n\",\n",
       "   '\\n',\n",
       "   '    # Man calls a pager, so we also need to redefine it\\n',\n",
       "   \"    if os.name == 'posix':\\n\",\n",
       "   '        @line_magic\\n',\n",
       "   '        def man(self, arg_s):\\n',\n",
       "   '            \"\"\"Find the man page for the given command and display in pager.\"\"\"\\n',\n",
       "   \"            page.page(self.shell.getoutput('man %s | col -b' % arg_s,\\n\",\n",
       "   '                                           split=False))\\n',\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   '    def connect_info(self, arg_s):\\n',\n",
       "   '        \"\"\"Print information for connecting other clients to this kernel\\n',\n",
       "   '\\n',\n",
       "   \"        It will print the contents of this session's connection file, as well as\\n\",\n",
       "   '        shortcuts for local clients.\\n',\n",
       "   '\\n',\n",
       "   '        In the simplest case, when called from the most recently launched kernel,\\n',\n",
       "   '        secondary clients can be connected, simply with:\\n',\n",
       "   '\\n',\n",
       "   '        $> ipython <app> --existing\\n',\n",
       "   '\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        from IPython.core.application import BaseIPythonApplication as BaseIPApp\\n',\n",
       "   '\\n',\n",
       "   '        if BaseIPApp.initialized():\\n',\n",
       "   '            app = BaseIPApp.instance()\\n',\n",
       "   '            security_dir = app.profile_dir.security_dir\\n',\n",
       "   '            profile = app.profile\\n',\n",
       "   '        else:\\n',\n",
       "   \"            profile = 'default'\\n\",\n",
       "   \"            security_dir = ''\\n\",\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   '            connection_file = get_connection_file()\\n',\n",
       "   '            info = get_connection_info(unpack=False)\\n',\n",
       "   '        except Exception as e:\\n',\n",
       "   '            error(\"Could not get connection info: %r\" % e)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        # add profile flag for non-default profile\\n',\n",
       "   '        profile_flag = \"--profile %s\" % profile if profile != \\'default\\' else \"\"\\n',\n",
       "   '\\n',\n",
       "   \"        # if it's in the security dir, truncate to basename\\n\",\n",
       "   '        if security_dir == os.path.dirname(connection_file):\\n',\n",
       "   '            connection_file = os.path.basename(connection_file)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   \"        print (info + '\\\\n')\\n\",\n",
       "   '        print (\"Paste the above JSON into a file, and connect with:\\\\n\"\\n',\n",
       "   '            \"    $> ipython <app> --existing <file>\\\\n\"\\n',\n",
       "   '            \"or, if you are local, you can connect with just:\\\\n\"\\n',\n",
       "   '            \"    $> ipython <app> --existing {0} {1}\\\\n\"\\n',\n",
       "   '            \"or even just:\\\\n\"\\n',\n",
       "   '            \"    $> ipython <app> --existing {1}\\\\n\"\\n',\n",
       "   '            \"if this is the most recent IPython session you have started.\".format(\\n',\n",
       "   '            connection_file, profile_flag\\n',\n",
       "   '            )\\n',\n",
       "   '        )\\n',\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   '    def qtconsole(self, arg_s):\\n',\n",
       "   '        \"\"\"Open a qtconsole connected to this kernel.\\n',\n",
       "   '\\n',\n",
       "   '        Useful for connecting a qtconsole to running notebooks, for better\\n',\n",
       "   '        debugging.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        # %qtconsole should imply bind_kernel for engines:\\n',\n",
       "   '        # FIXME: move to ipyparallel Kernel subclass\\n',\n",
       "   \"        if 'ipyparallel' in sys.modules:\\n\",\n",
       "   '            from ipyparallel import bind_kernel\\n',\n",
       "   '            bind_kernel()\\n',\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   \"            p = connect_qtconsole(argv=arg_split(arg_s, os.name=='posix'))\\n\",\n",
       "   '        except Exception as e:\\n',\n",
       "   '            error(\"Could not start qtconsole: %r\" % e)\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '    @line_magic\\n',\n",
       "   '    def autosave(self, arg_s):\\n',\n",
       "   '        \"\"\"Set the autosave interval in the notebook (in seconds).\\n',\n",
       "   '\\n',\n",
       "   '        The default value is 120, or two minutes.\\n',\n",
       "   '        ``%autosave 0`` will disable autosave.\\n',\n",
       "   '\\n',\n",
       "   '        This magic only has an effect when called from the notebook interface.\\n',\n",
       "   '        It has no effect when called in a startup file.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   '            interval = int(arg_s)\\n',\n",
       "   '        except ValueError:\\n',\n",
       "   '            raise UsageError(\"%%autosave requires an integer, got %r\" % arg_s)\\n',\n",
       "   '\\n',\n",
       "   '        # javascript wants milliseconds\\n',\n",
       "   '        milliseconds = 1000 * interval\\n',\n",
       "   '        display(Javascript(\"IPython.notebook.set_autosave_interval(%i)\" % milliseconds),\\n',\n",
       "   \"            include=['application/javascript']\\n\",\n",
       "   '        )\\n',\n",
       "   '        if interval:\\n',\n",
       "   '            print(\"Autosaving every %i seconds\" % interval)\\n',\n",
       "   '        else:\\n',\n",
       "   '            print(\"Autosave disabled\")\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class ZMQInteractiveShell(InteractiveShell):\\n',\n",
       "   '    \"\"\"A subclass of InteractiveShell for ZMQ.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    displayhook_class = Type(ZMQShellDisplayHook)\\n',\n",
       "   '    display_pub_class = Type(ZMQDisplayPublisher)\\n',\n",
       "   \"    data_pub_class = Type('ipykernel.datapub.ZMQDataPublisher')\\n\",\n",
       "   '    kernel = Any()\\n',\n",
       "   '    parent_header = Any()\\n',\n",
       "   '\\n',\n",
       "   '    def _banner1_default(self):\\n',\n",
       "   '        return default_banner\\n',\n",
       "   '\\n',\n",
       "   \"    # Override the traitlet in the parent class, because there's no point using\\n\",\n",
       "   '    # readline for the kernel. Can be removed when the readline code is moved\\n',\n",
       "   '    # to the terminal frontend.\\n',\n",
       "   '    colors_force = CBool(True)\\n',\n",
       "   '    readline_use = CBool(False)\\n',\n",
       "   '    # autoindent has no meaning in a zmqshell, and attempting to enable it\\n',\n",
       "   '    # will print a warning in the absence of readline.\\n',\n",
       "   '    autoindent = CBool(False)\\n',\n",
       "   '\\n',\n",
       "   '    exiter = Instance(ZMQExitAutocall)\\n',\n",
       "   '    def _exiter_default(self):\\n',\n",
       "   '        return ZMQExitAutocall(self)\\n',\n",
       "   '\\n',\n",
       "   '    def _exit_now_changed(self, name, old, new):\\n',\n",
       "   '        \"\"\"stop eventloop when exit_now fires\"\"\"\\n',\n",
       "   '        if new:\\n',\n",
       "   '            loop = ioloop.IOLoop.instance()\\n',\n",
       "   '            loop.add_timeout(time.time()+0.1, loop.stop)\\n',\n",
       "   '\\n',\n",
       "   '    keepkernel_on_exit = None\\n',\n",
       "   '\\n',\n",
       "   \"    # Over ZeroMQ, GUI control isn't done with PyOS_InputHook as there is no\\n\",\n",
       "   '    # interactive input being read; we provide event loop support in ipkernel\\n',\n",
       "   '    @staticmethod\\n',\n",
       "   '    def enable_gui(gui):\\n',\n",
       "   '        from .eventloops import enable_gui as real_enable_gui\\n',\n",
       "   '        try:\\n',\n",
       "   '            real_enable_gui(gui)\\n',\n",
       "   '        except ValueError as e:\\n',\n",
       "   '            raise UsageError(\"%s\" % e)\\n',\n",
       "   '\\n',\n",
       "   '    def init_environment(self):\\n',\n",
       "   '        \"\"\"Configure the user\\'s environment.\"\"\"\\n',\n",
       "   '        env = os.environ\\n',\n",
       "   \"        # These two ensure 'ls' produces nice coloring on BSD-derived systems\\n\",\n",
       "   \"        env['TERM'] = 'xterm-color'\\n\",\n",
       "   \"        env['CLICOLOR'] = '1'\\n\",\n",
       "   \"        # Since normal pagers don't work at all (over pexpect we don't have\\n\",\n",
       "   '        # single-key control of the subprocess), try to disable paging in\\n',\n",
       "   '        # subprocesses as much as possible.\\n',\n",
       "   \"        env['PAGER'] = 'cat'\\n\",\n",
       "   \"        env['GIT_PAGER'] = 'cat'\\n\",\n",
       "   '\\n',\n",
       "   '    def init_hooks(self):\\n',\n",
       "   '        super(ZMQInteractiveShell, self).init_hooks()\\n',\n",
       "   \"        self.set_hook('show_in_pager', page.as_hook(payloadpage.page), 99)\\n\",\n",
       "   '    \\n',\n",
       "   '    def init_data_pub(self):\\n',\n",
       "   '        \"\"\"Delay datapub init until request, for deprecation warnings\"\"\"\\n',\n",
       "   '        pass\\n',\n",
       "   '    \\n',\n",
       "   '    @property\\n',\n",
       "   '    def data_pub(self):\\n',\n",
       "   \"        if not hasattr(self, '_data_pub'):\\n\",\n",
       "   '            warnings.warn(\"InteractiveShell.data_pub is deprecated outside IPython parallel.\", \\n',\n",
       "   '                DeprecationWarning, stacklevel=2)\\n',\n",
       "   '            \\n',\n",
       "   '            self._data_pub = self.data_pub_class(parent=self)\\n',\n",
       "   '            self._data_pub.session = self.display_pub.session\\n',\n",
       "   '            self._data_pub.pub_socket = self.display_pub.pub_socket\\n',\n",
       "   '        return self._data_pub\\n',\n",
       "   '    \\n',\n",
       "   '    @data_pub.setter\\n',\n",
       "   '    def data_pub(self, pub):\\n',\n",
       "   '        self._data_pub = pub\\n',\n",
       "   '\\n',\n",
       "   '    def ask_exit(self):\\n',\n",
       "   '        \"\"\"Engage the exit actions.\"\"\"\\n',\n",
       "   '        self.exit_now = (not self.keepkernel_on_exit)\\n',\n",
       "   '        payload = dict(\\n',\n",
       "   \"            source='ask_exit',\\n\",\n",
       "   '            keepkernel=self.keepkernel_on_exit,\\n',\n",
       "   '            )\\n',\n",
       "   '        self.payload_manager.write_payload(payload)\\n',\n",
       "   '\\n',\n",
       "   '    def _showtraceback(self, etype, evalue, stb):\\n',\n",
       "   '        # try to preserve ordering of tracebacks and print statements\\n',\n",
       "   '        sys.stdout.flush()\\n',\n",
       "   '        sys.stderr.flush()\\n',\n",
       "   '\\n',\n",
       "   '        exc_content = {\\n',\n",
       "   \"            u'traceback' : stb,\\n\",\n",
       "   \"            u'ename' : unicode_type(etype.__name__),\\n\",\n",
       "   \"            u'evalue' : py3compat.safe_unicode(evalue),\\n\",\n",
       "   '        }\\n',\n",
       "   '\\n',\n",
       "   '        dh = self.displayhook\\n',\n",
       "   '        # Send exception info over pub socket for other clients than the caller\\n',\n",
       "   '        # to pick up\\n',\n",
       "   '        topic = None\\n',\n",
       "   '        if dh.topic:\\n',\n",
       "   \"            topic = dh.topic.replace(b'execute_result', b'error')\\n\",\n",
       "   '\\n',\n",
       "   \"        exc_msg = dh.session.send(dh.pub_socket, u'error', json_clean(exc_content), dh.parent_header, ident=topic)\\n\",\n",
       "   '\\n',\n",
       "   '        # FIXME - Hack: store exception info in shell object.  Right now, the\\n',\n",
       "   '        # caller is reading this info after the fact, we need to fix this logic\\n',\n",
       "   '        # to remove this hack.  Even uglier, we need to store the error status\\n',\n",
       "   '        # here, because in the main loop, the logic that sets it is being\\n',\n",
       "   '        # skipped because runlines swallows the exceptions.\\n',\n",
       "   \"        exc_content[u'status'] = u'error'\\n\",\n",
       "   '        self._reply_content = exc_content\\n',\n",
       "   '        # /FIXME\\n',\n",
       "   '\\n',\n",
       "   '        return exc_content\\n',\n",
       "   '\\n',\n",
       "   '    def set_next_input(self, text, replace=False):\\n',\n",
       "   '        \"\"\"Send the specified text to the frontend to be presented at the next\\n',\n",
       "   '        input cell.\"\"\"\\n',\n",
       "   '        payload = dict(\\n',\n",
       "   \"            source='set_next_input',\\n\",\n",
       "   '            text=text,\\n',\n",
       "   '            replace=replace,\\n',\n",
       "   '        )\\n',\n",
       "   '        self.payload_manager.write_payload(payload)\\n',\n",
       "   '\\n',\n",
       "   '    def set_parent(self, parent):\\n',\n",
       "   '        \"\"\"Set the parent header for associating output with its triggering input\"\"\"\\n',\n",
       "   '        self.parent_header = parent\\n',\n",
       "   '        self.displayhook.set_parent(parent)\\n',\n",
       "   '        self.display_pub.set_parent(parent)\\n',\n",
       "   \"        if hasattr(self, '_data_pub'):\\n\",\n",
       "   '            self.data_pub.set_parent(parent)\\n',\n",
       "   '        try:\\n',\n",
       "   '            sys.stdout.set_parent(parent)\\n',\n",
       "   '        except AttributeError:\\n',\n",
       "   '            pass\\n',\n",
       "   '        try:\\n',\n",
       "   '            sys.stderr.set_parent(parent)\\n',\n",
       "   '        except AttributeError:\\n',\n",
       "   '            pass\\n',\n",
       "   '\\n',\n",
       "   '    def get_parent(self):\\n',\n",
       "   '        return self.parent_header\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to magics\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def init_magics(self):\\n',\n",
       "   '        super(ZMQInteractiveShell, self).init_magics()\\n',\n",
       "   '        self.register_magics(KernelMagics)\\n',\n",
       "   \"        self.magics_manager.register_alias('ed', 'edit')\\n\",\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'InteractiveShellABC.register(ZMQInteractiveShell)\\n'],\n",
       "  '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/zmqshell.py'),\n",
       " <module 'ipykernel.datapub' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/datapub.py'>,\n",
       " {'Any': traitlets.traitlets.Any,\n",
       "  'CBytes': traitlets.traitlets.CBytes,\n",
       "  'Configurable': traitlets.config.configurable.Configurable,\n",
       "  'Dict': traitlets.traitlets.Dict,\n",
       "  'Instance': traitlets.traitlets.Instance,\n",
       "  'Session': jupyter_client.session.Session,\n",
       "  'ZMQDataPublisher': ipykernel.datapub.ZMQDataPublisher,\n",
       "  '__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/datapub.cpython-34.pyc',\n",
       "  '__doc__': 'Publishing native (typically pickled) objects.\\n',\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/datapub.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c124b780>,\n",
       "  '__name__': 'ipykernel.datapub',\n",
       "  '__package__': 'ipykernel',\n",
       "  '__spec__': ModuleSpec(name='ipykernel.datapub', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b780>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/datapub.py'),\n",
       "  '__warningregistry__': {'version': 4,\n",
       "   ('ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub',\n",
       "    DeprecationWarning,\n",
       "    5): True},\n",
       "  'extract_header': <function jupyter_client.session.extract_header>,\n",
       "  'json_clean': <function ipykernel.jsonutil.json_clean>,\n",
       "  'publish_data': <function ipykernel.datapub.publish_data>,\n",
       "  'serialize_object': <function ipykernel.serialize.serialize_object>,\n",
       "  'warnings': <module 'warnings' from '/usr/lib64/python3.4/warnings.py'>},\n",
       " ('publish a data_message on the IOPub channel\\n\\n    Parameters\\n    ----------\\n\\n    data : dict\\n        The data to be published. Think of it as a namespace.\\n    ',\n",
       "  'ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub',\n",
       "  0,\n",
       "  ('ZMQInteractiveShell',),\n",
       "  None),\n",
       " {'version': 4,\n",
       "  ('ipykernel.datapub is deprecated. It has moved to ipyparallel.datapub',\n",
       "   DeprecationWarning,\n",
       "   5): True},\n",
       " <module 'ipykernel.serialize' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/serialize.py'>,\n",
       " {'CannedObject': ipykernel.pickleutil.CannedObject,\n",
       "  'MAX_BYTES': 1024,\n",
       "  'MAX_ITEMS': 64,\n",
       "  'PICKLE_PROTOCOL': 3,\n",
       "  'PY3': True,\n",
       "  '__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/serialize.cpython-34.pyc',\n",
       "  '__doc__': 'serialization utilities for apply messages',\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/serialize.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c124b4a8>,\n",
       "  '__name__': 'ipykernel.serialize',\n",
       "  '__package__': 'ipykernel',\n",
       "  '__spec__': ModuleSpec(name='ipykernel.serialize', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b4a8>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/serialize.py'),\n",
       "  '__warningregistry__': {'version': 4,\n",
       "   ('ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize',\n",
       "    DeprecationWarning,\n",
       "    7): True},\n",
       "  '_extract_buffers': <function ipykernel.serialize._extract_buffers>,\n",
       "  '_restore_buffers': <function ipykernel.serialize._restore_buffers>,\n",
       "  'buffer': memoryview,\n",
       "  'buffer_to_bytes_py2': <function ipython_genutils.py3compat.no_code>,\n",
       "  'cPickle': None,\n",
       "  'can': <function ipykernel.pickleutil.can>,\n",
       "  'can_sequence': <function ipykernel.pickleutil.can_sequence>,\n",
       "  'chain': itertools.chain,\n",
       "  'deserialize_object': <function ipykernel.serialize.deserialize_object>,\n",
       "  'istype': <function ipykernel.pickleutil.istype>,\n",
       "  'pack_apply_message': <function ipykernel.serialize.pack_apply_message>,\n",
       "  'pickle': <module 'pickle' from '/usr/lib64/python3.4/pickle.py'>,\n",
       "  'sequence_types': (list, tuple, set),\n",
       "  'serialize_object': <function ipykernel.serialize.serialize_object>,\n",
       "  'uncan': <function ipykernel.pickleutil.uncan>,\n",
       "  'uncan_sequence': <function ipykernel.pickleutil.uncan_sequence>,\n",
       "  'unpack_apply_message': <function ipykernel.serialize.unpack_apply_message>,\n",
       "  'warnings': <module 'warnings' from '/usr/lib64/python3.4/warnings.py'>},\n",
       " {'version': 4,\n",
       "  ('ipykernel.serialize is deprecated. It has moved to ipyparallel.serialize',\n",
       "   DeprecationWarning,\n",
       "   7): True},\n",
       " <module 'ipykernel.pickleutil' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py'>,\n",
       " {'Application': traitlets.config.application.Application,\n",
       "  'CannedArray': ipykernel.pickleutil.CannedArray,\n",
       "  'CannedBuffer': ipykernel.pickleutil.CannedBuffer,\n",
       "  'CannedBytes': ipykernel.pickleutil.CannedBytes,\n",
       "  'CannedCell': ipykernel.pickleutil.CannedCell,\n",
       "  'CannedClass': ipykernel.pickleutil.CannedClass,\n",
       "  'CannedFunction': ipykernel.pickleutil.CannedFunction,\n",
       "  'CannedMemoryView': ipykernel.pickleutil.CannedMemoryView,\n",
       "  'CannedObject': ipykernel.pickleutil.CannedObject,\n",
       "  'FunctionType': function,\n",
       "  'PICKLE_PROTOCOL': 3,\n",
       "  'Reference': ipykernel.pickleutil.Reference,\n",
       "  '__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/pickleutil.cpython-34.pyc',\n",
       "  '__doc__': \"Pickle related utilities. Perhaps this should be called 'can'.\",\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c124b4e0>,\n",
       "  '__name__': 'ipykernel.pickleutil',\n",
       "  '__package__': 'ipykernel',\n",
       "  '__spec__': ModuleSpec(name='ipykernel.pickleutil', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b4e0>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py'),\n",
       "  '__warningregistry__': {'version': 4,\n",
       "   ('ipykernel.pickleutil is deprecated. It has moved to ipyparallel.',\n",
       "    DeprecationWarning,\n",
       "    8): True},\n",
       "  '_get_cell_type': <function ipykernel.pickleutil._get_cell_type>,\n",
       "  '_import_mapping': <function ipykernel.pickleutil._import_mapping>,\n",
       "  '_original_can_map': {'numpy.ndarray': ipykernel.pickleutil.CannedArray,\n",
       "   function: ipykernel.pickleutil.CannedFunction,\n",
       "   type: <function ipykernel.pickleutil.can_class>,\n",
       "   cell: ipykernel.pickleutil.CannedCell,\n",
       "   bytes: ipykernel.pickleutil.CannedBytes,\n",
       "   memoryview: ipykernel.pickleutil.CannedMemoryView},\n",
       "  '_original_uncan_map': {ipykernel.pickleutil.CannedObject: <function ipykernel.pickleutil.<lambda>>,\n",
       "   dict: <function ipykernel.pickleutil.uncan_dict>},\n",
       "  'buffer': memoryview,\n",
       "  'buffer_to_bytes': <function ipython_genutils.py3compat.buffer_to_bytes>,\n",
       "  'buffer_to_bytes_py2': <function ipython_genutils.py3compat.no_code>,\n",
       "  'can': <function ipykernel.pickleutil.can>,\n",
       "  'can_class': <function ipykernel.pickleutil.can_class>,\n",
       "  'can_dict': <function ipykernel.pickleutil.can_dict>,\n",
       "  'can_map': {'numpy.ndarray': ipykernel.pickleutil.CannedArray,\n",
       "   function: ipykernel.pickleutil.CannedFunction,\n",
       "   type: <function ipykernel.pickleutil.can_class>,\n",
       "   cell: ipykernel.pickleutil.CannedCell,\n",
       "   bytes: ipykernel.pickleutil.CannedBytes,\n",
       "   memoryview: ipykernel.pickleutil.CannedMemoryView},\n",
       "  'can_sequence': <function ipykernel.pickleutil.can_sequence>,\n",
       "  'cell_type': cell,\n",
       "  'class_type': type,\n",
       "  'codeutil': <module 'ipykernel.codeutil' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py'>,\n",
       "  'copy': <module 'copy' from '/usr/lib64/python3.4/copy.py'>,\n",
       "  'get_logger': <function traitlets.log.get_logger>,\n",
       "  'import_item': <function ipython_genutils.importstring.import_item>,\n",
       "  'interactive': <function ipykernel.pickleutil.interactive>,\n",
       "  'istype': <function ipykernel.pickleutil.istype>,\n",
       "  'iteritems': <function ipython_genutils.py3compat.iteritems>,\n",
       "  'logging': <module 'logging' from '/usr/lib64/python3.4/logging/__init__.py'>,\n",
       "  'pickle': <module 'pickle' from '/usr/lib64/python3.4/pickle.py'>,\n",
       "  'py3compat': <module 'ipython_genutils.py3compat' from '/home/pasha/.local/lib/python3.4/site-packages/ipython_genutils/py3compat.py'>,\n",
       "  'sequence_types': (list, tuple, set),\n",
       "  'string_types': (str,),\n",
       "  'sys': <module 'sys' (built-in)>,\n",
       "  'uncan': <function ipykernel.pickleutil.uncan>,\n",
       "  'uncan_dict': <function ipykernel.pickleutil.uncan_dict>,\n",
       "  'uncan_map': {ipykernel.pickleutil.CannedObject: <function ipykernel.pickleutil.<lambda>>,\n",
       "   dict: <function ipykernel.pickleutil.uncan_dict>},\n",
       "  'uncan_sequence': <function ipykernel.pickleutil.uncan_sequence>,\n",
       "  'use_cloudpickle': <function ipykernel.pickleutil.use_cloudpickle>,\n",
       "  'use_dill': <function ipykernel.pickleutil.use_dill>,\n",
       "  'warnings': <module 'warnings' from '/usr/lib64/python3.4/warnings.py'>},\n",
       " ('use dill to expand serialization support\\n    \\n    adds support for object methods and closures to serialization.\\n    ',\n",
       "  0,\n",
       "  None,\n",
       "  ('serialize',)),\n",
       " ('use cloudpickle to expand serialization support\\n    \\n    adds support for object methods and closures to serialization.\\n    ',\n",
       "  0,\n",
       "  None,\n",
       "  ('serialize',)),\n",
       " (None,\n",
       "  '__weakref__',\n",
       "  '__dict__',\n",
       "  <code object <listcomp> at 0x7f51c01a2540, file \"/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py\", line 250>,\n",
       "  'CannedClass.__init__.<locals>.<listcomp>',\n",
       "  1,\n",
       "  ('__weakref__', '__dict__')),\n",
       " (None,\n",
       "  0,\n",
       "  ('ascontiguousarray',),\n",
       "  False,\n",
       "  True,\n",
       "  'O',\n",
       "  <code object <genexpr> at 0x7f51c01a28a0, file \"/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py\", line 271>,\n",
       "  'CannedArray.__init__.<locals>.<genexpr>',\n",
       "  'dtype'),\n",
       " (None, 0, ('frombuffer',), 'dtype'),\n",
       " {'version': 4,\n",
       "  ('ipykernel.pickleutil is deprecated. It has moved to ipyparallel.',\n",
       "   DeprecationWarning,\n",
       "   8): True},\n",
       " <module 'ipykernel.codeutil' from '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py'>,\n",
       " {'__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/codeutil.cpython-34.pyc',\n",
       "  '__doc__': 'Utilities to enable code objects to be pickled.\\n\\nAny process that import this module will be able to pickle code objects.  This\\nincludes the func_code attribute of any function.  Once unpickled, new\\nfunctions can be built using new.function(code, globals()).  Eventually\\nwe need to automate all of this so that functions themselves can be pickled.\\n\\nReference: A. Tremols, P Cogolo, \"Python Cookbook,\" p 302-305\\n',\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c01a6278>,\n",
       "  '__name__': 'ipykernel.codeutil',\n",
       "  '__package__': 'ipykernel',\n",
       "  '__spec__': ModuleSpec(name='ipykernel.codeutil', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c01a6278>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py'),\n",
       "  '__warningregistry__': {'version': 4,\n",
       "   ('ipykernel.codeutil is deprecated. It has moved to ipyparallel.serialize',\n",
       "    DeprecationWarning,\n",
       "    17): True},\n",
       "  'code_ctor': <function ipykernel.codeutil.code_ctor>,\n",
       "  'copyreg': <module 'copyreg' from '/usr/lib64/python3.4/copyreg.py'>,\n",
       "  'reduce_code': <function ipykernel.codeutil.reduce_code>,\n",
       "  'sys': <module 'sys' (built-in)>,\n",
       "  'types': <module 'types' from '/usr/lib64/python3.4/types.py'>,\n",
       "  'warnings': <module 'warnings' from '/usr/lib64/python3.4/warnings.py'>},\n",
       " {'version': 4,\n",
       "  ('ipykernel.codeutil is deprecated. It has moved to ipyparallel.serialize',\n",
       "   DeprecationWarning,\n",
       "   17): True},\n",
       " <function ipykernel.codeutil.code_ctor>,\n",
       " <function ipykernel.codeutil.reduce_code>,\n",
       " <function ipykernel.pickleutil._get_cell_type>,\n",
       " <function ipykernel.pickleutil.interactive>,\n",
       " <function ipykernel.pickleutil.use_dill>,\n",
       " <function ipykernel.pickleutil.use_cloudpickle>,\n",
       " ipykernel.pickleutil.CannedObject,\n",
       " (ipykernel.pickleutil.CannedObject, object),\n",
       " <weakref at 0x7f51c0199b88; to 'type' at 0x55b8f537ad28 (CannedObject)>,\n",
       " ipykernel.pickleutil.Reference,\n",
       " (ipykernel.pickleutil.Reference, ipykernel.pickleutil.CannedObject, object),\n",
       " {94252876411256: <weakref at 0x7f51c0199c28; to 'type' at 0x55b8f537b178 (Reference)>,\n",
       "  94252876412296: <weakref at 0x7f51c0199c78; to 'type' at 0x55b8f537b588 (CannedCell)>,\n",
       "  94252876413192: <weakref at 0x7f51c0199cc8; to 'type' at 0x55b8f537b908 (CannedFunction)>,\n",
       "  94252876414232: <weakref at 0x7f51c0199d18; to 'type' at 0x55b8f537bd18 (CannedClass)>,\n",
       "  94252876415512: <weakref at 0x7f51c0199d68; to 'type' at 0x55b8f537c218 (CannedArray)>,\n",
       "  94252876416792: <weakref at 0x7f51c0199db8; to 'type' at 0x55b8f537c718 (CannedBytes)>},\n",
       " ipykernel.pickleutil.CannedCell,\n",
       " (ipykernel.pickleutil.CannedCell, ipykernel.pickleutil.CannedObject, object),\n",
       " <weakref at 0x7f51c0199c78; to 'type' at 0x55b8f537b588 (CannedCell)>,\n",
       " ipykernel.pickleutil.CannedFunction,\n",
       " (ipykernel.pickleutil.CannedFunction,\n",
       "  ipykernel.pickleutil.CannedObject,\n",
       "  object),\n",
       " <weakref at 0x7f51c0199cc8; to 'type' at 0x55b8f537b908 (CannedFunction)>,\n",
       " ipykernel.pickleutil.CannedClass,\n",
       " (ipykernel.pickleutil.CannedClass, ipykernel.pickleutil.CannedObject, object),\n",
       " <weakref at 0x7f51c0199d18; to 'type' at 0x55b8f537bd18 (CannedClass)>,\n",
       " ipykernel.pickleutil.CannedArray,\n",
       " (ipykernel.pickleutil.CannedArray, ipykernel.pickleutil.CannedObject, object),\n",
       " <weakref at 0x7f51c0199d68; to 'type' at 0x55b8f537c218 (CannedArray)>,\n",
       " ipykernel.pickleutil.CannedBytes,\n",
       " (ipykernel.pickleutil.CannedBytes, ipykernel.pickleutil.CannedObject, object),\n",
       " <weakref at 0x7f51c0199db8; to 'type' at 0x55b8f537c718 (CannedBytes)>,\n",
       " ipykernel.pickleutil.CannedBuffer,\n",
       " (ipykernel.pickleutil.CannedBuffer,\n",
       "  ipykernel.pickleutil.CannedBytes,\n",
       "  ipykernel.pickleutil.CannedObject,\n",
       "  object),\n",
       " {94252876418120: <weakref at 0x7f51c0199e08; to 'type' at 0x55b8f537cc48 (CannedBuffer)>,\n",
       "  94252876419640: <weakref at 0x7f51c0199ea8; to 'type' at 0x55b8f537d238 (CannedMemoryView)>},\n",
       " ipykernel.pickleutil.CannedMemoryView,\n",
       " (ipykernel.pickleutil.CannedMemoryView,\n",
       "  ipykernel.pickleutil.CannedBytes,\n",
       "  ipykernel.pickleutil.CannedObject,\n",
       "  object),\n",
       " <weakref at 0x7f51c0199ea8; to 'type' at 0x55b8f537d238 (CannedMemoryView)>,\n",
       " <function ipykernel.pickleutil._import_mapping>,\n",
       " <function ipykernel.pickleutil.istype>,\n",
       " <function ipykernel.pickleutil.can>,\n",
       " <function ipykernel.pickleutil.can_class>,\n",
       " <function ipykernel.pickleutil.can_dict>,\n",
       " <function ipykernel.pickleutil.can_sequence>,\n",
       " <function ipykernel.pickleutil.uncan>,\n",
       " <function ipykernel.pickleutil.uncan_dict>,\n",
       " <function ipykernel.pickleutil.uncan_sequence>,\n",
       " {'numpy.ndarray': ipykernel.pickleutil.CannedArray,\n",
       "  function: ipykernel.pickleutil.CannedFunction,\n",
       "  type: <function ipykernel.pickleutil.can_class>,\n",
       "  cell: ipykernel.pickleutil.CannedCell,\n",
       "  bytes: ipykernel.pickleutil.CannedBytes,\n",
       "  memoryview: ipykernel.pickleutil.CannedMemoryView},\n",
       " {ipykernel.pickleutil.CannedObject: <function ipykernel.pickleutil.<lambda>>,\n",
       "  dict: <function ipykernel.pickleutil.uncan_dict>},\n",
       " {'numpy.ndarray': ipykernel.pickleutil.CannedArray,\n",
       "  function: ipykernel.pickleutil.CannedFunction,\n",
       "  type: <function ipykernel.pickleutil.can_class>,\n",
       "  cell: ipykernel.pickleutil.CannedCell,\n",
       "  bytes: ipykernel.pickleutil.CannedBytes,\n",
       "  memoryview: ipykernel.pickleutil.CannedMemoryView},\n",
       " {ipykernel.pickleutil.CannedObject: <function ipykernel.pickleutil.<lambda>>,\n",
       "  dict: <function ipykernel.pickleutil.uncan_dict>},\n",
       " <function ipykernel.serialize._extract_buffers>,\n",
       " <function ipykernel.serialize._restore_buffers>,\n",
       " <function ipykernel.serialize.serialize_object>,\n",
       " <function ipykernel.serialize.deserialize_object>,\n",
       " <function ipykernel.serialize.pack_apply_message>,\n",
       " <function ipykernel.serialize.unpack_apply_message>,\n",
       " ipykernel.datapub.ZMQDataPublisher,\n",
       " (ipykernel.datapub.ZMQDataPublisher,\n",
       "  traitlets.config.configurable.Configurable,\n",
       "  traitlets.traitlets.HasTraits,\n",
       "  traitlets.traitlets._NewBase,\n",
       "  traitlets.traitlets.HasDescriptors,\n",
       "  traitlets.traitlets._NewBase,\n",
       "  object),\n",
       " <weakref at 0x7f51c0199228; to 'MetaHasTraits' at 0x55b8f537ebd8 (ZMQDataPublisher)>,\n",
       " <function ipykernel.datapub.publish_data>,\n",
       " {'_post_execute': {},\n",
       "  'alias_manager': <IPython.core.alias.AliasManager at 0x7f51c01137b8>,\n",
       "  'ast_node_interactivity': 'last_expr',\n",
       "  'ast_transformers': [],\n",
       "  'autocall': 0,\n",
       "  'autoindent': False,\n",
       "  'automagic': True,\n",
       "  'banner1': 'Python 3.4.3 (default, Jun 29 2015, 12:16:01) \\nType \"copyright\", \"credits\" or \"license\" for more information.\\n\\nIPython 4.1.2 -- An enhanced Interactive Python.\\n?         -> Introduction and overview of IPython\\'s features.\\n%quickref -> Quick reference.\\nhelp      -> Python\\'s own help system.\\nobject?   -> Details about \\'object\\', use \\'object??\\' for extra details.\\n',\n",
       "  'banner2': '',\n",
       "  'builtin_trap': <IPython.core.builtin_trap.BuiltinTrap at 0x7f51c016eef0>,\n",
       "  'cache_size': 1000,\n",
       "  'color_info': True,\n",
       "  'colors': 'Linux',\n",
       "  'colors_force': True,\n",
       "  'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'data_pub_class': ipykernel.datapub.ZMQDataPublisher,\n",
       "  'debug': False,\n",
       "  'deep_reload': False,\n",
       "  'disable_failing_post_execute': False,\n",
       "  'display_formatter': <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  'display_page': False,\n",
       "  'display_pub_class': ipykernel.zmqshell.ZMQDisplayPublisher,\n",
       "  'display_trap': <IPython.core.display_trap.DisplayTrap at 0x7f51c0113320>,\n",
       "  'displayhook_class': ipykernel.displayhook.ZMQShellDisplayHook,\n",
       "  'execution_count': 21,\n",
       "  'exit_now': False,\n",
       "  'exiter': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "  'extension_manager': <IPython.core.extensions.ExtensionManager at 0x7f51c0113eb8>,\n",
       "  'filename': '<ipython console>',\n",
       "  'history_length': 10000,\n",
       "  'history_load_length': 1000,\n",
       "  'history_manager': <IPython.core.history.HistoryManager at 0x7f51c1221710>,\n",
       "  'input_transformer_manager': <IPython.core.inputsplitter.IPythonInputSplitter at 0x7f51c00d4be0>,\n",
       "  'ipython_dir': '/home/pasha/.ipython',\n",
       "  'kernel': <ipykernel.ipkernel.IPythonKernel at 0x7f51c1221278>,\n",
       "  'logappend': '',\n",
       "  'logfile': '',\n",
       "  'logstart': False,\n",
       "  'magics_manager': <IPython.core.magic.MagicsManager at 0x7f51c0113470>,\n",
       "  'multiline_history': True,\n",
       "  'object_info_string_level': 0,\n",
       "  'parent': <ipykernel.ipkernel.IPythonKernel at 0x7f51c1221278>,\n",
       "  'parent_header': {'buffers': [],\n",
       "   'content': {'allow_stdin': True,\n",
       "    'code': 'gc.get_objects()',\n",
       "    'silent': False,\n",
       "    'stop_on_error': True,\n",
       "    'store_history': True,\n",
       "    'user_expressions': {}},\n",
       "   'header': {'date': '2016-03-20T19:46:05.318327',\n",
       "    'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "    'msg_type': 'execute_request',\n",
       "    'session': '4CE6797D9E26478A800FA96DD84CCB50',\n",
       "    'username': 'username',\n",
       "    'version': '5.0'},\n",
       "   'metadata': {},\n",
       "   'msg_id': 'BF3CEE6EC01944EEA25FA7825F7AD98A',\n",
       "   'msg_type': 'execute_request',\n",
       "   'parent_header': {}},\n",
       "  'payload_manager': <IPython.core.payload.PayloadManager at 0x7f51c01476a0>,\n",
       "  'pdb': False,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'profile_dir': <IPython.core.profiledir.ProfileDir at 0x7f51c1221518>,\n",
       "  'prompt_in1': 'In [\\\\#]: ',\n",
       "  'prompt_in2': '   .\\\\D.: ',\n",
       "  'prompt_out': 'Out[\\\\#]: ',\n",
       "  'prompts_pad_left': True,\n",
       "  'quiet': False,\n",
       "  'readline_delims': '',\n",
       "  'readline_remove_delims': '-/~',\n",
       "  'readline_use': False,\n",
       "  'separate_in': '\\n',\n",
       "  'separate_out': '',\n",
       "  'separate_out2': '',\n",
       "  'show_rewritten_input': True,\n",
       "  'wildcards_case_sensitive': True,\n",
       "  'xmode': 'Context'},\n",
       " [<ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "  <IPython.core.history.HistoryManager at 0x7f51c1221710>,\n",
       "  <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  <IPython.core.completer.IPCompleter at 0x7f51c0186080>,\n",
       "  <IPython.core.prompts.PromptManager at 0x7f51c01131d0>,\n",
       "  <IPython.core.formatters.DisplayFormatter at 0x7f51c0113400>,\n",
       "  <ipykernel.zmqshell.ZMQDisplayPublisher at 0x7f51c0113438>,\n",
       "  <ipykernel.displayhook.ZMQShellDisplayHook at 0x7f51c0113278>,\n",
       "  <IPython.core.magics.UserMagics at 0x7f51c01134a8>,\n",
       "  <IPython.core.magic.MagicsManager at 0x7f51c0113470>,\n",
       "  <IPython.core.magics.auto.AutoMagics at 0x7f51c0113a90>,\n",
       "  <IPython.core.magics.basic.BasicMagics at 0x7f51c0113b00>,\n",
       "  <IPython.core.magics.code.CodeMagics at 0x7f51c0113b38>,\n",
       "  <IPython.core.magics.config.ConfigMagics at 0x7f51c0113b70>,\n",
       "  <IPython.core.magics.deprecated.DeprecatedMagics at 0x7f51c0113ba8>,\n",
       "  <IPython.core.magics.display.DisplayMagics at 0x7f51c0113be0>,\n",
       "  <IPython.core.magics.execution.ExecutionMagics at 0x7f51c0113c18>,\n",
       "  <IPython.core.magics.extension.ExtensionMagics at 0x7f51c0113c50>,\n",
       "  <IPython.core.magics.history.HistoryMagics at 0x7f51c0113c88>,\n",
       "  <IPython.core.magics.logging.LoggingMagics at 0x7f51c0113cc0>,\n",
       "  <IPython.core.magics.namespace.NamespaceMagics at 0x7f51c0113cf8>,\n",
       "  <IPython.core.magics.osm.OSMagics at 0x7f51c0113d30>,\n",
       "  <IPython.core.magics.pylab.PylabMagics at 0x7f51c0113d68>,\n",
       "  <IPython.core.magics.script.ScriptMagics at 0x7f51c0113da0>,\n",
       "  <ipykernel.zmqshell.KernelMagics at 0x7f51c013b358>,\n",
       "  <IPython.core.alias.AliasManager at 0x7f51c01137b8>,\n",
       "  <IPython.core.extensions.ExtensionManager at 0x7f51c0113eb8>,\n",
       "  <IPython.core.payload.PayloadManager at 0x7f51c01476a0>,\n",
       "  <ipykernel.comm.manager.CommManager at 0x7f51c0147940>,\n",
       "  <ipykernel.kernelapp.IPKernelApp at 0x7f51d2a1ac18>,\n",
       "  <storemagic.StoreMagics at 0x7f51c01477b8>,\n",
       "  <storemagic.StoreMagics at 0x7f51c01477b8>],\n",
       " (132557,\n",
       "  1457880499.8382401,\n",
       "  ['# -*- coding: utf-8 -*-\\n',\n",
       "   '\"\"\"Main IPython class.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '#  Copyright (C) 2001 Janko Hauser <jhauser@zscout.de>\\n',\n",
       "   '#  Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>\\n',\n",
       "   '#  Copyright (C) 2008-2011  The IPython Development Team\\n',\n",
       "   '#\\n',\n",
       "   '#  Distributed under the terms of the BSD License.  The full license is in\\n',\n",
       "   '#  the file COPYING, distributed as part of this software.\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   'from __future__ import absolute_import, print_function\\n',\n",
       "   '\\n',\n",
       "   'import __future__\\n',\n",
       "   'import abc\\n',\n",
       "   'import ast\\n',\n",
       "   'import atexit\\n',\n",
       "   'import functools\\n',\n",
       "   'import os\\n',\n",
       "   'import re\\n',\n",
       "   'import runpy\\n',\n",
       "   'import sys\\n',\n",
       "   'import tempfile\\n',\n",
       "   'import traceback\\n',\n",
       "   'import types\\n',\n",
       "   'import subprocess\\n',\n",
       "   'import warnings\\n',\n",
       "   'from io import open as io_open\\n',\n",
       "   '\\n',\n",
       "   'from pickleshare import PickleShareDB\\n',\n",
       "   '\\n',\n",
       "   'from traitlets.config.configurable import SingletonConfigurable\\n',\n",
       "   'from IPython.core import debugger, oinspect\\n',\n",
       "   'from IPython.core import magic\\n',\n",
       "   'from IPython.core import page\\n',\n",
       "   'from IPython.core import prefilter\\n',\n",
       "   'from IPython.core import shadowns\\n',\n",
       "   'from IPython.core import ultratb\\n',\n",
       "   'from IPython.core.alias import Alias, AliasManager\\n',\n",
       "   'from IPython.core.autocall import ExitAutocall\\n',\n",
       "   'from IPython.core.builtin_trap import BuiltinTrap\\n',\n",
       "   'from IPython.core.events import EventManager, available_events\\n',\n",
       "   'from IPython.core.compilerop import CachingCompiler, check_linecache_ipython\\n',\n",
       "   'from IPython.core.display_trap import DisplayTrap\\n',\n",
       "   'from IPython.core.displayhook import DisplayHook\\n',\n",
       "   'from IPython.core.displaypub import DisplayPublisher\\n',\n",
       "   'from IPython.core.error import InputRejected, UsageError\\n',\n",
       "   'from IPython.core.extensions import ExtensionManager\\n',\n",
       "   'from IPython.core.formatters import DisplayFormatter\\n',\n",
       "   'from IPython.core.history import HistoryManager\\n',\n",
       "   'from IPython.core.inputsplitter import IPythonInputSplitter, ESC_MAGIC, ESC_MAGIC2\\n',\n",
       "   'from IPython.core.logger import Logger\\n',\n",
       "   'from IPython.core.macro import Macro\\n',\n",
       "   'from IPython.core.payload import PayloadManager\\n',\n",
       "   'from IPython.core.prefilter import PrefilterManager\\n',\n",
       "   'from IPython.core.profiledir import ProfileDir\\n',\n",
       "   'from IPython.core.prompts import PromptManager\\n',\n",
       "   'from IPython.core.usage import default_banner\\n',\n",
       "   'from IPython.testing.skipdoctest import skip_doctest\\n',\n",
       "   'from IPython.utils import PyColorize\\n',\n",
       "   'from IPython.utils import io\\n',\n",
       "   'from IPython.utils import py3compat\\n',\n",
       "   'from IPython.utils import openpy\\n',\n",
       "   'from IPython.utils.contexts import NoOpContext\\n',\n",
       "   'from IPython.utils.decorators import undoc\\n',\n",
       "   'from IPython.utils.io import ask_yes_no\\n',\n",
       "   'from IPython.utils.ipstruct import Struct\\n',\n",
       "   'from IPython.paths import get_ipython_dir\\n',\n",
       "   'from IPython.utils.path import get_home_dir, get_py_filename, unquote_filename, ensure_dir_exists\\n',\n",
       "   'from IPython.utils.process import system, getoutput\\n',\n",
       "   'from IPython.utils.py3compat import (builtin_mod, unicode_type, string_types,\\n',\n",
       "   '                                     with_metaclass, iteritems)\\n',\n",
       "   'from IPython.utils.strdispatch import StrDispatch\\n',\n",
       "   'from IPython.utils.syspathcontext import prepended_to_syspath\\n',\n",
       "   'from IPython.utils.text import (format_screen, LSString, SList,\\n',\n",
       "   '                                DollarFormatter)\\n',\n",
       "   'from traitlets import (Integer, Bool, CBool, CaselessStrEnum, Enum,\\n',\n",
       "   '                                     List, Dict, Unicode, Instance, Type)\\n',\n",
       "   'from IPython.utils.warn import warn, error\\n',\n",
       "   'import IPython.core.hooks\\n',\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '# Globals\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '# compiled regexps for autoindent management\\n',\n",
       "   \"dedent_re = re.compile(r'^\\\\s+raise|^\\\\s+return|^\\\\s+pass')\\n\",\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '# Utilities\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '@undoc\\n',\n",
       "   'def softspace(file, newvalue):\\n',\n",
       "   '    \"\"\"Copied from code.py, to remove the dependency\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    oldvalue = 0\\n',\n",
       "   '    try:\\n',\n",
       "   '        oldvalue = file.softspace\\n',\n",
       "   '    except AttributeError:\\n',\n",
       "   '        pass\\n',\n",
       "   '    try:\\n',\n",
       "   '        file.softspace = newvalue\\n',\n",
       "   '    except (AttributeError, TypeError):\\n',\n",
       "   '        # \"attribute-less object\" or \"read-only attributes\"\\n',\n",
       "   '        pass\\n',\n",
       "   '    return oldvalue\\n',\n",
       "   '\\n',\n",
       "   '@undoc\\n',\n",
       "   'def no_op(*a, **kw): pass\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class SpaceInInput(Exception): pass\\n',\n",
       "   '\\n',\n",
       "   '@undoc\\n',\n",
       "   'class Bunch: pass\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'def get_default_colors():\\n',\n",
       "   \"    if sys.platform=='darwin':\\n\",\n",
       "   '        return \"LightBG\"\\n',\n",
       "   \"    elif os.name=='nt':\\n\",\n",
       "   \"        return 'Linux'\\n\",\n",
       "   '    else:\\n',\n",
       "   \"        return 'Linux'\\n\",\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class SeparateUnicode(Unicode):\\n',\n",
       "   '    r\"\"\"A Unicode subclass to validate separate_in, separate_out, etc.\\n',\n",
       "   '\\n',\n",
       "   \"    This is a Unicode based trait that converts '0'->'' and ``'\\\\\\\\n'->'\\\\n'``.\\n\",\n",
       "   '    \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    def validate(self, obj, value):\\n',\n",
       "   \"        if value == '0': value = ''\\n\",\n",
       "   \"        value = value.replace('\\\\\\\\n','\\\\n')\\n\",\n",
       "   '        return super(SeparateUnicode, self).validate(obj, value)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '@undoc\\n',\n",
       "   'class DummyMod(object):\\n',\n",
       "   '    \"\"\"A dummy module used for IPython\\'s interactive module when\\n',\n",
       "   '    a namespace must be assigned to the module\\'s __dict__.\"\"\"\\n',\n",
       "   '    pass\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class ExecutionResult(object):\\n',\n",
       "   '    \"\"\"The result of a call to :meth:`InteractiveShell.run_cell`\\n',\n",
       "   '\\n',\n",
       "   '    Stores information about what took place.\\n',\n",
       "   '    \"\"\"\\n',\n",
       "   '    execution_count = None\\n',\n",
       "   '    error_before_exec = None\\n',\n",
       "   '    error_in_exec = None\\n',\n",
       "   '    result = None\\n',\n",
       "   '\\n',\n",
       "   '    @property\\n',\n",
       "   '    def success(self):\\n',\n",
       "   '        return (self.error_before_exec is None) and (self.error_in_exec is None)\\n',\n",
       "   '\\n',\n",
       "   '    def raise_error(self):\\n',\n",
       "   '        \"\"\"Reraises error if `success` is `False`, otherwise does nothing\"\"\"\\n',\n",
       "   '        if self.error_before_exec is not None:\\n',\n",
       "   '            raise self.error_before_exec\\n',\n",
       "   '        if self.error_in_exec is not None:\\n',\n",
       "   '            raise self.error_in_exec\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class InteractiveShell(SingletonConfigurable):\\n',\n",
       "   '    \"\"\"An enhanced, interactive shell for Python.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    _instance = None\\n',\n",
       "   '    \\n',\n",
       "   '    ast_transformers = List([], config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        A list of ast.NodeTransformer subclass instances, which will be applied\\n',\n",
       "   '        to user input before code is run.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    autocall = Enum((0,1,2), default_value=0, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        Make IPython automatically call any callable object even if you didn't\\n\",\n",
       "   \"        type explicit parentheses. For example, 'str 43' becomes 'str(43)'\\n\",\n",
       "   \"        automatically. The value can be '0' to disable the feature, '1' for\\n\",\n",
       "   \"        'smart' autocall, where it is not applied if there are no more\\n\",\n",
       "   \"        arguments on the line, and '2' for 'full' autocall, where all callable\\n\",\n",
       "   '        objects are automatically called (even if no arguments are present).\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    # TODO: remove all autoindent logic and put into frontends.\\n',\n",
       "   \"    # We can't do this yet because even runlines uses the autoindent.\\n\",\n",
       "   '    autoindent = CBool(True, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Autoindent IPython code entered interactively.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    automagic = CBool(True, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Enable magic commands to be called without the leading %.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    \\n',\n",
       "   '    banner1 = Unicode(default_banner, config=True,\\n',\n",
       "   '        help=\"\"\"The part of the banner to be printed before the profile\"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   \"    banner2 = Unicode('', config=True,\\n\",\n",
       "   '        help=\"\"\"The part of the banner to be printed after the profile\"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    cache_size = Integer(1000, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Set the size of the output cache.  The default is 1000, you can\\n',\n",
       "   '        change it permanently in your config file.  Setting it to 0 completely\\n',\n",
       "   '        disables the caching system, and the minimum value accepted is 20 (if\\n',\n",
       "   '        you provide a value less than 20, it is reset to 0 and a warning is\\n',\n",
       "   \"        issued).  This limit is defined because otherwise you'll spend more\\n\",\n",
       "   '        time re-flushing a too small cache than working\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    color_info = CBool(True, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Use colors for displaying information about objects. Because this\\n',\n",
       "   \"        information is passed through a pager (like 'less'), and some pagers\\n\",\n",
       "   '        get confused with color codes, this capability can be turned off.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   \"    colors = CaselessStrEnum(('NoColor','LightBG','Linux'),\\n\",\n",
       "   '                             default_value=get_default_colors(), config=True,\\n',\n",
       "   '        help=\"Set the color scheme (NoColor, Linux, or LightBG).\"\\n',\n",
       "   '    )\\n',\n",
       "   '    colors_force = CBool(False, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Force use of ANSI color codes, regardless of OS and readline\\n',\n",
       "   '        availability.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        # FIXME: This is essentially a hack to allow ZMQShell to show colors\\n',\n",
       "   '        # without readline on Win32. When the ZMQ formatting system is\\n',\n",
       "   '        # refactored, this should be removed.\\n',\n",
       "   '    )\\n',\n",
       "   '    debug = CBool(False, config=True)\\n',\n",
       "   '    deep_reload = CBool(False, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        **Deprecated**\\n',\n",
       "   '\\n',\n",
       "   '        Will be removed in IPython 6.0\\n',\n",
       "   '\\n',\n",
       "   '        Enable deep (recursive) reloading by default. IPython can use the\\n',\n",
       "   '        deep_reload module which reloads changes in modules recursively (it\\n',\n",
       "   \"        replaces the reload() function, so you don't need to change anything to\\n\",\n",
       "   '        use it). `deep_reload` forces a full reload of modules whose code may\\n',\n",
       "   '        have changed, which the default reload() function does not.  When\\n',\n",
       "   '        deep_reload is off, IPython will use the normal reload(), but\\n',\n",
       "   '        deep_reload will still be available as dreload().\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    disable_failing_post_execute = CBool(False, config=True,\\n',\n",
       "   '        help=\"Don\\'t call post-execute functions that have failed in the past.\"\\n',\n",
       "   '    )\\n',\n",
       "   '    display_formatter = Instance(DisplayFormatter, allow_none=True)\\n',\n",
       "   '    displayhook_class = Type(DisplayHook)\\n',\n",
       "   '    display_pub_class = Type(DisplayPublisher)\\n',\n",
       "   '    data_pub_class = None\\n',\n",
       "   '\\n',\n",
       "   '    exit_now = CBool(False)\\n',\n",
       "   '    exiter = Instance(ExitAutocall)\\n',\n",
       "   '    def _exiter_default(self):\\n',\n",
       "   '        return ExitAutocall(self)\\n',\n",
       "   '    # Monotonically increasing execution counter\\n',\n",
       "   '    execution_count = Integer(1)\\n',\n",
       "   '    filename = Unicode(\"<ipython console>\")\\n',\n",
       "   \"    ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__\\n\",\n",
       "   '\\n',\n",
       "   '    # Input splitter, to transform input line by line and detect when a block\\n',\n",
       "   '    # is ready to be executed.\\n',\n",
       "   \"    input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter',\\n\",\n",
       "   \"                              (), {'line_input_checker': True})\\n\",\n",
       "   '    \\n',\n",
       "   '    # This InputSplitter instance is used to transform completed cells before\\n',\n",
       "   '    # running them. It allows cell magics to contain blank lines.\\n',\n",
       "   \"    input_transformer_manager = Instance('IPython.core.inputsplitter.IPythonInputSplitter',\\n\",\n",
       "   \"                                         (), {'line_input_checker': False})\\n\",\n",
       "   '    \\n',\n",
       "   '    logstart = CBool(False, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Start logging to the default log file in overwrite mode.\\n',\n",
       "   '        Use `logappend` to specify a log file to **append** logs to.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   \"    logfile = Unicode('', config=True, help=\\n\",\n",
       "   '        \"\"\"\\n',\n",
       "   '        The name of the logfile to use.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   \"    logappend = Unicode('', config=True, help=\\n\",\n",
       "   '        \"\"\"\\n',\n",
       "   '        Start logging to the given file in append mode.\\n',\n",
       "   '        Use `logfile` to specify a log file to **overwrite** logs to.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    object_info_string_level = Enum((0,1,2), default_value=0,\\n',\n",
       "   '                                    config=True)\\n',\n",
       "   '    pdb = CBool(False, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        Automatically call the pdb debugger after every exception.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   \"    multiline_history = CBool(sys.platform != 'win32', config=True,\\n\",\n",
       "   '        help=\"Save multi-line entries as one entry in readline history\"\\n',\n",
       "   '    )\\n',\n",
       "   '    display_page = Bool(False, config=True,\\n',\n",
       "   '        help=\"\"\"If True, anything that would be passed to the pager\\n',\n",
       "   '        will be displayed as regular output instead.\"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    # deprecated prompt traits:\\n',\n",
       "   '    \\n',\n",
       "   \"    prompt_in1 = Unicode('In [\\\\\\\\#]: ', config=True,\\n\",\n",
       "   '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.in_template\")\\n',\n",
       "   \"    prompt_in2 = Unicode('   .\\\\\\\\D.: ', config=True,\\n\",\n",
       "   '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.in2_template\")\\n',\n",
       "   \"    prompt_out = Unicode('Out[\\\\\\\\#]: ', config=True,\\n\",\n",
       "   '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.out_template\")\\n',\n",
       "   '    prompts_pad_left = CBool(True, config=True,\\n',\n",
       "   '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.justify\")\\n',\n",
       "   '    \\n',\n",
       "   '    def _prompt_trait_changed(self, name, old, new):\\n',\n",
       "   '        table = {\\n',\n",
       "   \"            'prompt_in1' : 'in_template',\\n\",\n",
       "   \"            'prompt_in2' : 'in2_template',\\n\",\n",
       "   \"            'prompt_out' : 'out_template',\\n\",\n",
       "   \"            'prompts_pad_left' : 'justify',\\n\",\n",
       "   '        }\\n',\n",
       "   '        warn(\"InteractiveShell.{name} is deprecated, use PromptManager.{newname}\".format(\\n',\n",
       "   '                name=name, newname=table[name])\\n',\n",
       "   '        )\\n',\n",
       "   '        # protect against weird cases where self.config may not exist:\\n',\n",
       "   '        if self.config is not None:\\n',\n",
       "   '            # propagate to corresponding PromptManager trait\\n',\n",
       "   '            setattr(self.config.PromptManager, table[name], new)\\n',\n",
       "   '    \\n',\n",
       "   '    _prompt_in1_changed = _prompt_trait_changed\\n',\n",
       "   '    _prompt_in2_changed = _prompt_trait_changed\\n',\n",
       "   '    _prompt_out_changed = _prompt_trait_changed\\n',\n",
       "   '    _prompt_pad_left_changed = _prompt_trait_changed\\n',\n",
       "   '    \\n',\n",
       "   '    show_rewritten_input = CBool(True, config=True,\\n',\n",
       "   '        help=\"Show rewritten input, e.g. for autocall.\"\\n',\n",
       "   '    )\\n',\n",
       "   '    \\n',\n",
       "   '    quiet = CBool(False, config=True)\\n',\n",
       "   '\\n',\n",
       "   '    history_length = Integer(10000, config=True)\\n',\n",
       "   '\\n',\n",
       "   '    history_load_length = Integer(1000, config=True, help=\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        The number of saved history entries to be loaded\\n',\n",
       "   '        into the readline buffer at startup.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    # The readline stuff will eventually be moved to the terminal subclass\\n',\n",
       "   \"    # but for now, we can't do that as readline is welded in everywhere.\\n\",\n",
       "   '    readline_use = CBool(True, config=True)\\n',\n",
       "   \"    readline_remove_delims = Unicode('-/~', config=True)\\n\",\n",
       "   '    readline_delims = Unicode() # set by init_readline()\\n',\n",
       "   \"    # don't use \\\\M- bindings by default, because they\\n\",\n",
       "   '    # conflict with 8-bit encodings. See gh-58,gh-88\\n',\n",
       "   '    readline_parse_and_bind = List([\\n',\n",
       "   \"            'tab: complete',\\n\",\n",
       "   '            \\'\"\\\\C-l\": clear-screen\\',\\n',\n",
       "   \"            'set show-all-if-ambiguous on',\\n\",\n",
       "   '            \\'\"\\\\C-o\": tab-insert\\',\\n',\n",
       "   '            \\'\"\\\\C-r\": reverse-search-history\\',\\n',\n",
       "   '            \\'\"\\\\C-s\": forward-search-history\\',\\n',\n",
       "   '            \\'\"\\\\C-p\": history-search-backward\\',\\n',\n",
       "   '            \\'\"\\\\C-n\": history-search-forward\\',\\n',\n",
       "   '            \\'\"\\\\e[A\": history-search-backward\\',\\n',\n",
       "   '            \\'\"\\\\e[B\": history-search-forward\\',\\n',\n",
       "   '            \\'\"\\\\C-k\": kill-line\\',\\n',\n",
       "   '            \\'\"\\\\C-u\": unix-line-discard\\',\\n',\n",
       "   '        ], config=True)\\n',\n",
       "   '    \\n',\n",
       "   '    _custom_readline_config = False\\n',\n",
       "   '    \\n',\n",
       "   '    def _readline_parse_and_bind_changed(self, name, old, new):\\n',\n",
       "   '        # notice that readline config is customized\\n',\n",
       "   '        # indicates that it should have higher priority than inputrc\\n',\n",
       "   '        self._custom_readline_config = True\\n',\n",
       "   '    \\n',\n",
       "   \"    ast_node_interactivity = Enum(['all', 'last', 'last_expr', 'none'],\\n\",\n",
       "   \"                                  default_value='last_expr', config=True, \\n\",\n",
       "   '                                  help=\"\"\"\\n',\n",
       "   \"        'all', 'last', 'last_expr' or 'none', specifying which nodes should be\\n\",\n",
       "   '        run interactively (displaying output from expressions).\"\"\")\\n',\n",
       "   '\\n',\n",
       "   '    # TODO: this part of prompt management should be moved to the frontends.\\n',\n",
       "   \"    # Use custom TraitTypes that convert '0'->'' and '\\\\\\\\n'->'\\\\n'\\n\",\n",
       "   \"    separate_in = SeparateUnicode('\\\\n', config=True)\\n\",\n",
       "   \"    separate_out = SeparateUnicode('', config=True)\\n\",\n",
       "   \"    separate_out2 = SeparateUnicode('', config=True)\\n\",\n",
       "   '    wildcards_case_sensitive = CBool(True, config=True)\\n',\n",
       "   \"    xmode = CaselessStrEnum(('Context','Plain', 'Verbose'),\\n\",\n",
       "   \"                            default_value='Context', config=True)\\n\",\n",
       "   '\\n',\n",
       "   '    # Subcomponents of InteractiveShell\\n',\n",
       "   \"    alias_manager = Instance('IPython.core.alias.AliasManager', allow_none=True)\\n\",\n",
       "   \"    prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True)\\n\",\n",
       "   \"    builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap', allow_none=True)\\n\",\n",
       "   \"    display_trap = Instance('IPython.core.display_trap.DisplayTrap', allow_none=True)\\n\",\n",
       "   \"    extension_manager = Instance('IPython.core.extensions.ExtensionManager', allow_none=True)\\n\",\n",
       "   \"    payload_manager = Instance('IPython.core.payload.PayloadManager', allow_none=True)\\n\",\n",
       "   \"    history_manager = Instance('IPython.core.history.HistoryAccessorBase', allow_none=True)\\n\",\n",
       "   \"    magics_manager = Instance('IPython.core.magic.MagicsManager', allow_none=True)\\n\",\n",
       "   '\\n',\n",
       "   \"    profile_dir = Instance('IPython.core.application.ProfileDir', allow_none=True)\\n\",\n",
       "   '    @property\\n',\n",
       "   '    def profile(self):\\n',\n",
       "   '        if self.profile_dir is not None:\\n',\n",
       "   '            name = os.path.basename(self.profile_dir.location)\\n',\n",
       "   \"            return name.replace('profile_','')\\n\",\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '    # Private interface\\n',\n",
       "   '    _post_execute = Dict()\\n',\n",
       "   '\\n',\n",
       "   '    # Tracks any GUI loop loaded for pylab\\n',\n",
       "   '    pylab_gui_select = None\\n',\n",
       "   '\\n',\n",
       "   '    def __init__(self, ipython_dir=None, profile_dir=None,\\n',\n",
       "   '                 user_module=None, user_ns=None,\\n',\n",
       "   '                 custom_exceptions=((), None), **kwargs):\\n',\n",
       "   '\\n',\n",
       "   '        # This is where traits with a config_key argument are updated\\n',\n",
       "   '        # from the values on config.\\n',\n",
       "   '        super(InteractiveShell, self).__init__(**kwargs)\\n',\n",
       "   '        self.configurables = [self]\\n',\n",
       "   '\\n',\n",
       "   '        # These are relatively independent and stateless\\n',\n",
       "   '        self.init_ipython_dir(ipython_dir)\\n',\n",
       "   '        self.init_profile_dir(profile_dir)\\n',\n",
       "   '        self.init_instance_attrs()\\n',\n",
       "   '        self.init_environment()\\n',\n",
       "   '        \\n',\n",
       "   \"        # Check if we're in a virtualenv, and set up sys.path.\\n\",\n",
       "   '        self.init_virtualenv()\\n',\n",
       "   '\\n',\n",
       "   '        # Create namespaces (user_ns, user_global_ns, etc.)\\n',\n",
       "   '        self.init_create_namespaces(user_module, user_ns)\\n',\n",
       "   '        # This has to be done after init_create_namespaces because it uses\\n',\n",
       "   '        # something in self.user_ns, but before init_sys_modules, which\\n',\n",
       "   '        # is the first thing to modify sys.\\n',\n",
       "   '        # TODO: When we override sys.stdout and sys.stderr before this class\\n',\n",
       "   '        # is created, we are saving the overridden ones here. Not sure if this\\n',\n",
       "   '        # is what we want to do.\\n',\n",
       "   '        self.save_sys_module_state()\\n',\n",
       "   '        self.init_sys_modules()\\n',\n",
       "   '\\n',\n",
       "   \"        # While we're trying to have each part of the code directly access what\\n\",\n",
       "   '        # it needs without keeping redundant references to objects, we have too\\n',\n",
       "   '        # much legacy code that expects ip.db to exist.\\n',\n",
       "   \"        self.db = PickleShareDB(os.path.join(self.profile_dir.location, 'db'))\\n\",\n",
       "   '\\n',\n",
       "   '        self.init_history()\\n',\n",
       "   '        self.init_encoding()\\n',\n",
       "   '        self.init_prefilter()\\n',\n",
       "   '\\n',\n",
       "   '        self.init_syntax_highlighting()\\n',\n",
       "   '        self.init_hooks()\\n',\n",
       "   '        self.init_events()\\n',\n",
       "   '        self.init_pushd_popd_magic()\\n',\n",
       "   '        # self.init_traceback_handlers use to be here, but we moved it below\\n',\n",
       "   '        # because it and init_io have to come after init_readline.\\n',\n",
       "   '        self.init_user_ns()\\n',\n",
       "   '        self.init_logger()\\n',\n",
       "   '        self.init_builtins()\\n',\n",
       "   '\\n',\n",
       "   '        # The following was in post_config_initialization\\n',\n",
       "   '        self.init_inspector()\\n',\n",
       "   '        # init_readline() must come before init_io(), because init_io uses\\n',\n",
       "   '        # readline related things.\\n',\n",
       "   '        self.init_readline()\\n',\n",
       "   '        # We save this here in case user code replaces raw_input, but it needs\\n',\n",
       "   \"        # to be after init_readline(), because PyPy's readline works by replacing\\n\",\n",
       "   '        # raw_input.\\n',\n",
       "   '        if py3compat.PY3:\\n',\n",
       "   '            self.raw_input_original = input\\n',\n",
       "   '        else:\\n',\n",
       "   '            self.raw_input_original = raw_input\\n',\n",
       "   '        # init_completer must come after init_readline, because it needs to\\n',\n",
       "   '        # know whether readline is present or not system-wide to configure the\\n',\n",
       "   '        # completers, since the completion machinery can now operate\\n',\n",
       "   '        # independently of readline (e.g. over the network)\\n',\n",
       "   '        self.init_completer()\\n',\n",
       "   '        # TODO: init_io() needs to happen before init_traceback handlers\\n',\n",
       "   '        # because the traceback handlers hardcode the stdout/stderr streams.\\n',\n",
       "   '        # This logic in in debugger.Pdb and should eventually be changed.\\n',\n",
       "   '        self.init_io()\\n',\n",
       "   '        self.init_traceback_handlers(custom_exceptions)\\n',\n",
       "   '        self.init_prompts()\\n',\n",
       "   '        self.init_display_formatter()\\n',\n",
       "   '        self.init_display_pub()\\n',\n",
       "   '        self.init_data_pub()\\n',\n",
       "   '        self.init_displayhook()\\n',\n",
       "   '        self.init_magics()\\n',\n",
       "   '        self.init_alias()\\n',\n",
       "   '        self.init_logstart()\\n',\n",
       "   '        self.init_pdb()\\n',\n",
       "   '        self.init_extension_manager()\\n',\n",
       "   '        self.init_payload()\\n',\n",
       "   '        self.init_deprecation_warnings()\\n',\n",
       "   '        self.hooks.late_startup_hook()\\n',\n",
       "   \"        self.events.trigger('shell_initialized', self)\\n\",\n",
       "   '        atexit.register(self.atexit_operations)\\n',\n",
       "   '\\n',\n",
       "   '    def get_ipython(self):\\n',\n",
       "   '        \"\"\"Return the currently running IPython instance.\"\"\"\\n',\n",
       "   '        return self\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Trait changed handlers\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def _ipython_dir_changed(self, name, new):\\n',\n",
       "   '        ensure_dir_exists(new)\\n',\n",
       "   '\\n',\n",
       "   '    def set_autoindent(self,value=None):\\n',\n",
       "   '        \"\"\"Set the autoindent flag, checking for readline support.\\n',\n",
       "   '\\n',\n",
       "   '        If called with no arguments, it acts as a toggle.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        if value != 0 and not self.has_readline:\\n',\n",
       "   \"            if os.name == 'posix':\\n\",\n",
       "   '                warn(\"The auto-indent feature requires the readline library\")\\n',\n",
       "   '            self.autoindent = 0\\n',\n",
       "   '            return\\n',\n",
       "   '        if value is None:\\n',\n",
       "   '            self.autoindent = not self.autoindent\\n',\n",
       "   '        else:\\n',\n",
       "   '            self.autoindent = value\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # init_* methods called by __init__\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def init_ipython_dir(self, ipython_dir):\\n',\n",
       "   '        if ipython_dir is not None:\\n',\n",
       "   '            self.ipython_dir = ipython_dir\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        self.ipython_dir = get_ipython_dir()\\n',\n",
       "   '\\n',\n",
       "   '    def init_profile_dir(self, profile_dir):\\n',\n",
       "   '        if profile_dir is not None:\\n',\n",
       "   '            self.profile_dir = profile_dir\\n',\n",
       "   '            return\\n',\n",
       "   '        self.profile_dir =\\\\\\n',\n",
       "   \"            ProfileDir.create_profile_dir_by_name(self.ipython_dir, 'default')\\n\",\n",
       "   '\\n',\n",
       "   '    def init_instance_attrs(self):\\n',\n",
       "   '        self.more = False\\n',\n",
       "   '\\n',\n",
       "   '        # command compiler\\n',\n",
       "   '        self.compile = CachingCompiler()\\n',\n",
       "   '\\n',\n",
       "   '        # Make an empty namespace, which extension writers can rely on both\\n',\n",
       "   '        # existing and NEVER being used by ipython itself.  This gives them a\\n',\n",
       "   '        # convenient location for storing additional information and state\\n',\n",
       "   '        # their extensions may require, without fear of collisions with other\\n',\n",
       "   '        # ipython names that may develop later.\\n',\n",
       "   '        self.meta = Struct()\\n',\n",
       "   '\\n',\n",
       "   '        # Temporary files used for various purposes.  Deleted at exit.\\n',\n",
       "   '        self.tempfiles = []\\n',\n",
       "   '        self.tempdirs = []\\n',\n",
       "   '\\n',\n",
       "   '        # Keep track of readline usage (later set by init_readline)\\n',\n",
       "   '        self.has_readline = False\\n',\n",
       "   '\\n',\n",
       "   '        # keep track of where we started running (mainly for crash post-mortem)\\n',\n",
       "   '        # This is not being used anywhere currently.\\n',\n",
       "   '        self.starting_dir = py3compat.getcwd()\\n',\n",
       "   '\\n',\n",
       "   '        # Indentation management\\n',\n",
       "   '        self.indent_current_nsp = 0\\n',\n",
       "   '\\n',\n",
       "   '        # Dict to track post-execution functions that have been registered\\n',\n",
       "   '        self._post_execute = {}\\n',\n",
       "   '\\n',\n",
       "   '    def init_environment(self):\\n',\n",
       "   '        \"\"\"Any changes we need to make to the user\\'s environment.\"\"\"\\n',\n",
       "   '        pass\\n',\n",
       "   '\\n',\n",
       "   '    def init_encoding(self):\\n',\n",
       "   '        # Get system encoding at startup time.  Certain terminals (like Emacs\\n',\n",
       "   '        # under Win32 have it set to None, and we need to have a known valid\\n',\n",
       "   '        # encoding to use in the raw_input() method\\n',\n",
       "   '        try:\\n',\n",
       "   \"            self.stdin_encoding = sys.stdin.encoding or 'ascii'\\n\",\n",
       "   '        except AttributeError:\\n',\n",
       "   \"            self.stdin_encoding = 'ascii'\\n\",\n",
       "   '\\n',\n",
       "   '    def init_syntax_highlighting(self):\\n',\n",
       "   '        # Python source parser/formatter for syntax highlighting\\n',\n",
       "   '        pyformat = PyColorize.Parser().format\\n',\n",
       "   \"        self.pycolorize = lambda src: pyformat(src,'str',self.colors)\\n\",\n",
       "   '\\n',\n",
       "   '    def init_pushd_popd_magic(self):\\n',\n",
       "   '        # for pushd/popd management\\n',\n",
       "   '        self.home_dir = get_home_dir()\\n',\n",
       "   '\\n',\n",
       "   '        self.dir_stack = []\\n',\n",
       "   '\\n',\n",
       "   '    def init_logger(self):\\n',\n",
       "   \"        self.logger = Logger(self.home_dir, logfname='ipython_log.py',\\n\",\n",
       "   \"                             logmode='rotate')\\n\",\n",
       "   '\\n',\n",
       "   '    def init_logstart(self):\\n',\n",
       "   '        \"\"\"Initialize logging in case it was requested at the command line.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if self.logappend:\\n',\n",
       "   \"            self.magic('logstart %s append' % self.logappend)\\n\",\n",
       "   '        elif self.logfile:\\n',\n",
       "   \"            self.magic('logstart %s' % self.logfile)\\n\",\n",
       "   '        elif self.logstart:\\n',\n",
       "   \"            self.magic('logstart')\\n\",\n",
       "   '\\n',\n",
       "   '    def init_deprecation_warnings(self):\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        register default filter for deprecation warning.\\n',\n",
       "   '\\n',\n",
       "   '        This will allow deprecation warning of function used interactively to show\\n',\n",
       "   '        warning to users, and still hide deprecation warning from libraries import.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        warnings.filterwarnings(\"default\", category=DeprecationWarning, module=self.user_ns.get(\"__name__\"))\\n',\n",
       "   '\\n',\n",
       "   '    def init_builtins(self):\\n',\n",
       "   '        # A single, static flag that we set to True.  Its presence indicates\\n',\n",
       "   '        # that an IPython shell has been created, and we make no attempts at\\n',\n",
       "   '        # removing on exit or representing the existence of more than one\\n',\n",
       "   '        # IPython at a time.\\n',\n",
       "   \"        builtin_mod.__dict__['__IPYTHON__'] = True\\n\",\n",
       "   '\\n',\n",
       "   \"        # In 0.11 we introduced '__IPYTHON__active' as an integer we'd try to\\n\",\n",
       "   \"        # manage on enter/exit, but with all our shells it's virtually\\n\",\n",
       "   \"        # impossible to get all the cases right.  We're leaving the name in for\\n\",\n",
       "   '        # those who adapted their codes to check for this flag, but will\\n',\n",
       "   '        # eventually remove it after a few more releases.\\n',\n",
       "   \"        builtin_mod.__dict__['__IPYTHON__active'] = \\\\\\n\",\n",
       "   \"                                          'Deprecated, check for __IPYTHON__'\\n\",\n",
       "   '\\n',\n",
       "   '        self.builtin_trap = BuiltinTrap(shell=self)\\n',\n",
       "   '\\n',\n",
       "   '    def init_inspector(self):\\n',\n",
       "   '        # Object inspector\\n',\n",
       "   '        self.inspector = oinspect.Inspector(oinspect.InspectColors,\\n',\n",
       "   '                                            PyColorize.ANSICodeColors,\\n',\n",
       "   \"                                            'NoColor',\\n\",\n",
       "   '                                            self.object_info_string_level)\\n',\n",
       "   '\\n',\n",
       "   '    def init_io(self):\\n',\n",
       "   '        # This will just use sys.stdout and sys.stderr. If you want to\\n',\n",
       "   '        # override sys.stdout and sys.stderr themselves, you need to do that\\n',\n",
       "   '        # *before* instantiating this class, because io holds onto\\n',\n",
       "   '        # references to the underlying streams.\\n',\n",
       "   \"        if (sys.platform == 'win32' or sys.platform == 'cli') and self.has_readline:\\n\",\n",
       "   '            io.stdout = io.stderr = io.IOStream(self.readline._outputfile)\\n',\n",
       "   '        else:\\n',\n",
       "   '            io.stdout = io.IOStream(sys.stdout)\\n',\n",
       "   '            io.stderr = io.IOStream(sys.stderr)\\n',\n",
       "   '\\n',\n",
       "   '    def init_prompts(self):\\n',\n",
       "   '        self.prompt_manager = PromptManager(shell=self, parent=self)\\n',\n",
       "   '        self.configurables.append(self.prompt_manager)\\n',\n",
       "   '        # Set system prompts, so that scripts can decide if they are running\\n',\n",
       "   '        # interactively.\\n',\n",
       "   \"        sys.ps1 = 'In : '\\n\",\n",
       "   \"        sys.ps2 = '...: '\\n\",\n",
       "   \"        sys.ps3 = 'Out: '\\n\",\n",
       "   '\\n',\n",
       "   '    def init_display_formatter(self):\\n',\n",
       "   '        self.display_formatter = DisplayFormatter(parent=self)\\n',\n",
       "   '        self.configurables.append(self.display_formatter)\\n',\n",
       "   '\\n',\n",
       "   '    def init_display_pub(self):\\n',\n",
       "   '        self.display_pub = self.display_pub_class(parent=self)\\n',\n",
       "   '        self.configurables.append(self.display_pub)\\n',\n",
       "   '\\n',\n",
       "   '    def init_data_pub(self):\\n',\n",
       "   '        if not self.data_pub_class:\\n',\n",
       "   '            self.data_pub = None\\n',\n",
       "   '            return\\n',\n",
       "   '        self.data_pub = self.data_pub_class(parent=self)\\n',\n",
       "   '        self.configurables.append(self.data_pub)\\n',\n",
       "   '\\n',\n",
       "   '    def init_displayhook(self):\\n',\n",
       "   '        # Initialize displayhook, set in/out prompts and printing system\\n',\n",
       "   '        self.displayhook = self.displayhook_class(\\n',\n",
       "   '            parent=self,\\n',\n",
       "   '            shell=self,\\n',\n",
       "   '            cache_size=self.cache_size,\\n',\n",
       "   '        )\\n',\n",
       "   '        self.configurables.append(self.displayhook)\\n',\n",
       "   '        # This is a context manager that installs/revmoes the displayhook at\\n',\n",
       "   '        # the appropriate time.\\n',\n",
       "   '        self.display_trap = DisplayTrap(hook=self.displayhook)\\n',\n",
       "   '\\n',\n",
       "   '    def init_virtualenv(self):\\n',\n",
       "   '        \"\"\"Add a virtualenv to sys.path so the user can import modules from it.\\n',\n",
       "   \"        This isn't perfect: it doesn't use the Python interpreter with which the\\n\",\n",
       "   '        virtualenv was built, and it ignores the --no-site-packages option. A\\n',\n",
       "   '        warning will appear suggesting the user installs IPython in the\\n',\n",
       "   '        virtualenv, but for many cases, it probably works well enough.\\n',\n",
       "   '        \\n',\n",
       "   '        Adapted from code snippets online.\\n',\n",
       "   '        \\n',\n",
       "   '        http://blog.ufsoft.org/2009/1/29/ipython-and-virtualenv\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        if 'VIRTUAL_ENV' not in os.environ:\\n\",\n",
       "   '            # Not in a virtualenv\\n',\n",
       "   '            return\\n',\n",
       "   '        \\n',\n",
       "   '        # venv detection:\\n',\n",
       "   \"        # stdlib venv may symlink sys.executable, so we can't use realpath.\\n\",\n",
       "   \"        # but others can symlink *to* the venv Python, so we can't just use sys.executable.\\n\",\n",
       "   '        # So we just check every item in the symlink tree (generally <= 3)\\n',\n",
       "   '        p = os.path.normcase(sys.executable)\\n',\n",
       "   '        paths = [p]\\n',\n",
       "   '        while os.path.islink(p):\\n',\n",
       "   '            p = os.path.normcase(os.path.join(os.path.dirname(p), os.readlink(p)))\\n',\n",
       "   '            paths.append(p)\\n',\n",
       "   \"        p_venv = os.path.normcase(os.environ['VIRTUAL_ENV'])\\n\",\n",
       "   '        if any(p.startswith(p_venv) for p in paths):\\n',\n",
       "   \"            # Running properly in the virtualenv, don't need to do anything\\n\",\n",
       "   '            return\\n',\n",
       "   '        \\n',\n",
       "   '        warn(\"Attempting to work in a virtualenv. If you encounter problems, please \"\\n',\n",
       "   '             \"install IPython inside the virtualenv.\")\\n',\n",
       "   '        if sys.platform == \"win32\":\\n',\n",
       "   \"            virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'Lib', 'site-packages') \\n\",\n",
       "   '        else:\\n',\n",
       "   \"            virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'lib',\\n\",\n",
       "   \"                       'python%d.%d' % sys.version_info[:2], 'site-packages')\\n\",\n",
       "   '        \\n',\n",
       "   '        import site\\n',\n",
       "   '        sys.path.insert(0, virtual_env)\\n',\n",
       "   '        site.addsitedir(virtual_env)\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to injections into the sys module\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def save_sys_module_state(self):\\n',\n",
       "   '        \"\"\"Save the state of hooks in the sys module.\\n',\n",
       "   '\\n',\n",
       "   '        This has to be called after self.user_module is created.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        self._orig_sys_module_state = {'stdin': sys.stdin,\\n\",\n",
       "   \"                                       'stdout': sys.stdout,\\n\",\n",
       "   \"                                       'stderr': sys.stderr,\\n\",\n",
       "   \"                                       'excepthook': sys.excepthook}\\n\",\n",
       "   '        self._orig_sys_modules_main_name = self.user_module.__name__\\n',\n",
       "   '        self._orig_sys_modules_main_mod = sys.modules.get(self.user_module.__name__)\\n',\n",
       "   '\\n',\n",
       "   '    def restore_sys_module_state(self):\\n',\n",
       "   '        \"\"\"Restore the state of the sys module.\"\"\"\\n',\n",
       "   '        try:\\n',\n",
       "   '            for k, v in iteritems(self._orig_sys_module_state):\\n',\n",
       "   '                setattr(sys, k, v)\\n',\n",
       "   '        except AttributeError:\\n',\n",
       "   '            pass\\n',\n",
       "   '        # Reset what what done in self.init_sys_modules\\n',\n",
       "   '        if self._orig_sys_modules_main_mod is not None:\\n',\n",
       "   '            sys.modules[self._orig_sys_modules_main_name] = self._orig_sys_modules_main_mod\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to the banner\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    \\n',\n",
       "   '    @property\\n',\n",
       "   '    def banner(self):\\n',\n",
       "   '        banner = self.banner1\\n',\n",
       "   \"        if self.profile and self.profile != 'default':\\n\",\n",
       "   \"            banner += '\\\\nIPython profile: %s\\\\n' % self.profile\\n\",\n",
       "   '        if self.banner2:\\n',\n",
       "   \"            banner += '\\\\n' + self.banner2\\n\",\n",
       "   '        return banner\\n',\n",
       "   '\\n',\n",
       "   '    def show_banner(self, banner=None):\\n',\n",
       "   '        if banner is None:\\n',\n",
       "   '            banner = self.banner\\n',\n",
       "   '        self.write(banner)\\n',\n",
       "   '    \\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to hooks\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def init_hooks(self):\\n',\n",
       "   '        # hooks holds pointers used for user-side customizations\\n',\n",
       "   '        self.hooks = Struct()\\n',\n",
       "   '\\n',\n",
       "   '        self.strdispatchers = {}\\n',\n",
       "   '\\n',\n",
       "   '        # Set all default hooks, defined in the IPython.hooks module.\\n',\n",
       "   '        hooks = IPython.core.hooks\\n',\n",
       "   '        for hook_name in hooks.__all__:\\n',\n",
       "   '            # default hooks have priority 100, i.e. low; user hooks should have\\n',\n",
       "   '            # 0-100 priority\\n',\n",
       "   '            self.set_hook(hook_name,getattr(hooks,hook_name), 100, _warn_deprecated=False)\\n',\n",
       "   '        \\n',\n",
       "   '        if self.display_page:\\n',\n",
       "   \"            self.set_hook('show_in_pager', page.as_hook(page.display_page), 90)\\n\",\n",
       "   '    \\n',\n",
       "   '    def set_hook(self,name,hook, priority=50, str_key=None, re_key=None,\\n',\n",
       "   '                 _warn_deprecated=True):\\n',\n",
       "   '        \"\"\"set_hook(name,hook) -> sets an internal IPython hook.\\n',\n",
       "   '\\n',\n",
       "   '        IPython exposes some of its internal API as user-modifiable hooks.  By\\n',\n",
       "   \"        adding your function to one of these hooks, you can modify IPython's\\n\",\n",
       "   '        behavior to call at runtime your own routines.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        # At some point in the future, this should validate the hook before it\\n',\n",
       "   '        # accepts it.  Probably at least check that the hook takes the number\\n',\n",
       "   \"        # of args it's supposed to.\\n\",\n",
       "   '\\n',\n",
       "   '        f = types.MethodType(hook,self)\\n',\n",
       "   '\\n',\n",
       "   '        # check if the hook is for strdispatcher first\\n',\n",
       "   '        if str_key is not None:\\n',\n",
       "   '            sdp = self.strdispatchers.get(name, StrDispatch())\\n',\n",
       "   '            sdp.add_s(str_key, f, priority )\\n',\n",
       "   '            self.strdispatchers[name] = sdp\\n',\n",
       "   '            return\\n',\n",
       "   '        if re_key is not None:\\n',\n",
       "   '            sdp = self.strdispatchers.get(name, StrDispatch())\\n',\n",
       "   '            sdp.add_re(re.compile(re_key), f, priority )\\n',\n",
       "   '            self.strdispatchers[name] = sdp\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        dp = getattr(self.hooks, name, None)\\n',\n",
       "   '        if name not in IPython.core.hooks.__all__:\\n',\n",
       "   '            print(\"Warning! Hook \\'%s\\' is not one of %s\" % \\\\\\n',\n",
       "   '                  (name, IPython.core.hooks.__all__ ))\\n',\n",
       "   '\\n',\n",
       "   '        if _warn_deprecated and (name in IPython.core.hooks.deprecated):\\n',\n",
       "   '            alternative = IPython.core.hooks.deprecated[name]\\n',\n",
       "   '            warn(\"Hook {} is deprecated. Use {} instead.\".format(name, alternative))\\n',\n",
       "   '\\n',\n",
       "   '        if not dp:\\n',\n",
       "   '            dp = IPython.core.hooks.CommandChainDispatcher()\\n',\n",
       "   '\\n',\n",
       "   '        try:\\n',\n",
       "   '            dp.add(f,priority)\\n',\n",
       "   '        except AttributeError:\\n',\n",
       "   '            # it was not commandchain, plain old func - replace\\n',\n",
       "   '            dp = f\\n',\n",
       "   '\\n',\n",
       "   '        setattr(self.hooks,name, dp)\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to events\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def init_events(self):\\n',\n",
       "   '        self.events = EventManager(self, available_events)\\n',\n",
       "   '\\n',\n",
       "   '        self.events.register(\"pre_execute\", self._clear_warning_registry)\\n',\n",
       "   '\\n',\n",
       "   '    def register_post_execute(self, func):\\n',\n",
       "   '        \"\"\"DEPRECATED: Use ip.events.register(\\'post_run_cell\\', func)\\n',\n",
       "   '        \\n',\n",
       "   '        Register a function for calling after code execution.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        warn(\"ip.register_post_execute is deprecated, use \"\\n',\n",
       "   '             \"ip.events.register(\\'post_run_cell\\', func) instead.\")\\n',\n",
       "   \"        self.events.register('post_run_cell', func)\\n\",\n",
       "   '    \\n',\n",
       "   '    def _clear_warning_registry(self):\\n',\n",
       "   '        # clear the warning registry, so that different code blocks with\\n',\n",
       "   \"        # overlapping line number ranges don't cause spurious suppression of\\n\",\n",
       "   '        # warnings (see gh-6611 for details)\\n',\n",
       "   '        if \"__warningregistry__\" in self.user_global_ns:\\n',\n",
       "   '            del self.user_global_ns[\"__warningregistry__\"]\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to the \"main\" module\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def new_main_mod(self, filename, modname):\\n',\n",
       "   '        \"\"\"Return a new \\'main\\' module object for user code execution.\\n',\n",
       "   '        \\n',\n",
       "   '        ``filename`` should be the path of the script which will be run in the\\n',\n",
       "   '        module. Requests with the same filename will get the same module, with\\n',\n",
       "   '        its namespace cleared.\\n',\n",
       "   '        \\n',\n",
       "   \"        ``modname`` should be the module name - normally either '__main__' or\\n\",\n",
       "   '        the basename of the file without the extension.\\n',\n",
       "   '        \\n',\n",
       "   '        When scripts are executed via %run, we must keep a reference to their\\n',\n",
       "   \"        __main__ module around so that Python doesn't\\n\",\n",
       "   '        clear it, rendering references to module globals useless.\\n',\n",
       "   '\\n',\n",
       "   '        This method keeps said reference in a private dict, keyed by the\\n',\n",
       "   '        absolute path of the script. This way, for multiple executions of the\\n',\n",
       "   '        same script we only keep one copy of the namespace (the last one),\\n',\n",
       "   '        thus preventing memory leaks from old references while allowing the\\n',\n",
       "   '        objects from the last execution to be accessible.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        filename = os.path.abspath(filename)\\n',\n",
       "   '        try:\\n',\n",
       "   '            main_mod = self._main_mod_cache[filename]\\n',\n",
       "   '        except KeyError:\\n',\n",
       "   '            main_mod = self._main_mod_cache[filename] = types.ModuleType(\\n',\n",
       "   '                        py3compat.cast_bytes_py2(modname),\\n',\n",
       "   '                        doc=\"Module created for script run in IPython\")\\n',\n",
       "   '        else:\\n',\n",
       "   '            main_mod.__dict__.clear()\\n',\n",
       "   '            main_mod.__name__ = modname\\n',\n",
       "   '        \\n',\n",
       "   '        main_mod.__file__ = filename\\n',\n",
       "   '        # It seems pydoc (and perhaps others) needs any module instance to\\n',\n",
       "   '        # implement a __nonzero__ method\\n',\n",
       "   '        main_mod.__nonzero__ = lambda : True\\n',\n",
       "   '        \\n',\n",
       "   '        return main_mod\\n',\n",
       "   '\\n',\n",
       "   '    def clear_main_mod_cache(self):\\n',\n",
       "   '        \"\"\"Clear the cache of main modules.\\n',\n",
       "   '\\n',\n",
       "   '        Mainly for use by utilities like %reset.\\n',\n",
       "   '\\n',\n",
       "   '        Examples\\n',\n",
       "   '        --------\\n',\n",
       "   '\\n',\n",
       "   '        In [15]: import IPython\\n',\n",
       "   '\\n',\n",
       "   \"        In [16]: m = _ip.new_main_mod(IPython.__file__, 'IPython')\\n\",\n",
       "   '\\n',\n",
       "   '        In [17]: len(_ip._main_mod_cache) > 0\\n',\n",
       "   '        Out[17]: True\\n',\n",
       "   '\\n',\n",
       "   '        In [18]: _ip.clear_main_mod_cache()\\n',\n",
       "   '\\n',\n",
       "   '        In [19]: len(_ip._main_mod_cache) == 0\\n',\n",
       "   '        Out[19]: True\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        self._main_mod_cache.clear()\\n',\n",
       "   '\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '    # Things related to debugging\\n',\n",
       "   '    #-------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '    def init_pdb(self):\\n',\n",
       "   '        # Set calling of pdb on exceptions\\n',\n",
       "   '        # self.call_pdb is a property\\n',\n",
       "   '        self.call_pdb = self.pdb\\n',\n",
       "   '\\n',\n",
       "   '    def _get_call_pdb(self):\\n',\n",
       "   '        return self._call_pdb\\n',\n",
       "   '\\n',\n",
       "   '    def _set_call_pdb(self,val):\\n',\n",
       "   '\\n',\n",
       "   '        if val not in (0,1,False,True):\\n',\n",
       "   \"            raise ValueError('new call_pdb value must be boolean')\\n\",\n",
       "   '\\n',\n",
       "   '        # store value in instance\\n',\n",
       "   '        self._call_pdb = val\\n',\n",
       "   '\\n',\n",
       "   '        # notify the actual exception handlers\\n',\n",
       "   '        self.InteractiveTB.call_pdb = val\\n',\n",
       "   '\\n',\n",
       "   '    call_pdb = property(_get_call_pdb,_set_call_pdb,None,\\n',\n",
       "   \"                        'Control auto-activation of pdb at exceptions')\\n\",\n",
       "   '\\n',\n",
       "   '    def debugger(self,force=False):\\n',\n",
       "   '        \"\"\"Call the pydb/pdb debugger.\\n',\n",
       "   '\\n',\n",
       "   '        Keywords:\\n',\n",
       "   '\\n',\n",
       "   '          - force(False): by default, this routine checks the instance call_pdb\\n',\n",
       "   '            flag and does not actually invoke the debugger if the flag is false.\\n',\n",
       "   \"            The 'force' option forces the debugger to activate even if the flag\\n\",\n",
       "   '            is false.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '        if not (force or self.call_pdb):\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   \"        if not hasattr(sys,'last_traceback'):\\n\",\n",
       "   \"            error('No traceback has been produced, nothing to debug.')\\n\",\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        # use pydb if available\\n',\n",
       "   '        if debugger.has_pydb:\\n',\n",
       "   '            from pydb import pm\\n',\n",
       "   '        else:\\n',\n",
       "   '            # fallback to our internal debugger\\n',\n",
       "   '            pm = lambda : self.InteractiveTB.debugger(force=True)\\n',\n",
       "   '\\n',\n",
       "   ...],\n",
       "  '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/interactiveshell.py'),\n",
       " <IPython.core.compilerop.CachingCompiler at 0x7f51c124b748>,\n",
       " {},\n",
       " [],\n",
       " [],\n",
       " <module '__main__'>,\n",
       " {'In': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "  '_': [],\n",
       "  '_14': 3,\n",
       "  '_15': 3,\n",
       "  '_19': <module 'gc' (built-in)>,\n",
       "  '_20': [],\n",
       "  '__': <module 'gc' (built-in)>,\n",
       "  '___': 3,\n",
       "  '__builtin__': <module 'builtins' (built-in)>,\n",
       "  '__builtins__': <module 'builtins' (built-in)>,\n",
       "  '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "  '__loader__': None,\n",
       "  '__name__': '__main__',\n",
       "  '__package__': None,\n",
       "  '__spec__': None,\n",
       "  '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "  '_i': 'import gc\\ngc.garbage',\n",
       "  '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "  '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "  '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "  '_i15': 'pick([1, 2, 3], 2)',\n",
       "  '_i16': \"pick([1, 2, 3], '2')\",\n",
       "  '_i17': 'import gc',\n",
       "  '_i18': 'import gc\\nпс',\n",
       "  '_i19': 'import gc\\ngc',\n",
       "  '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  '_i20': 'import gc\\ngc.garbage',\n",
       "  '_i21': 'gc.get_objects()',\n",
       "  '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "  '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_ih': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  '_ii': 'import gc\\ngc',\n",
       "  '_iii': 'import gc\\nпс',\n",
       "  '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "  '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "  'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "  'gc': <module 'gc' (built-in)>,\n",
       "  'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "  'pick': <function __main__.pick>,\n",
       "  'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "  'v': 3,\n",
       "  'x': {1: False, 3: True}},\n",
       " {'builtin': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  'user_global': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}},\n",
       "  'user_local': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}}},\n",
       " {'excepthook': <bound method IPKernelApp.excepthook of <ipykernel.kernelapp.IPKernelApp object at 0x7f51d2a1ac18>>,\n",
       "  'stderr': <ipykernel.iostream.OutStream at 0x7f51c1221b38>,\n",
       "  'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='UTF-8'>,\n",
       "  'stdout': <ipykernel.iostream.OutStream at 0x7f51c1221b70>},\n",
       " PickleShareDB('/home/pasha/.ipython/profile_default/db'),\n",
       " {'cache': {}, 'root': Path('/home/pasha/.ipython/profile_default/db')},\n",
       " <IPython.core.history.HistoryManager at 0x7f51c1221710>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'_i': 'import gc\\ngc.garbage',\n",
       "   '_i00': 'gc.get_objects()',\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'connection_options': {},\n",
       "   'db': <sqlite3.Connection at 0x7f51c12c0e30>,\n",
       "   'db_cache_size': 0,\n",
       "   'db_input_cache': [],\n",
       "   'db_log_output': False,\n",
       "   'db_output_cache': [],\n",
       "   'dir_hist': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   'enabled': True,\n",
       "   'hist_file': '/home/pasha/.ipython/profile_default/history.sqlite',\n",
       "   'input_hist_parsed': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'input_hist_raw': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'output_hist': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   'output_hist_reprs': {14: '3',\n",
       "    15: '3',\n",
       "    19: \"<module 'gc' (built-in)>\",\n",
       "    20: '[]'},\n",
       "   'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "   'save_flag': <threading.Event at 0x7f51c016e0f0>,\n",
       "   'save_thread': <HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>,\n",
       "   'session_number': 291,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       "  'db_input_cache_lock': <_thread.lock at 0x7f51c12897d8>,\n",
       "  'db_output_cache_lock': <_thread.lock at 0x7f51c1289aa8>},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " (31768,\n",
       "  1457880499.8372402,\n",
       "  ['\"\"\" History related magics and functionality \"\"\"\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '#  Copyright (C) 2010-2011 The IPython Development Team.\\n',\n",
       "   '#\\n',\n",
       "   '#  Distributed under the terms of the BSD License.\\n',\n",
       "   '#\\n',\n",
       "   '#  The full license is in the file COPYING.txt, distributed with this software.\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '# Imports\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   'from __future__ import print_function\\n',\n",
       "   '\\n',\n",
       "   '# Stdlib imports\\n',\n",
       "   'import atexit\\n',\n",
       "   'import datetime\\n',\n",
       "   'import os\\n',\n",
       "   'import re\\n',\n",
       "   'try:\\n',\n",
       "   '    import sqlite3\\n',\n",
       "   'except ImportError:\\n',\n",
       "   '    try:\\n',\n",
       "   '        from pysqlite2 import dbapi2 as sqlite3\\n',\n",
       "   '    except ImportError:\\n',\n",
       "   '        sqlite3 = None\\n',\n",
       "   'import threading\\n',\n",
       "   '\\n',\n",
       "   '# Our own packages\\n',\n",
       "   'from traitlets.config.configurable import Configurable\\n',\n",
       "   'from decorator import decorator\\n',\n",
       "   'from IPython.utils.decorators import undoc\\n',\n",
       "   'from IPython.utils.path import locate_profile\\n',\n",
       "   'from IPython.utils import py3compat\\n',\n",
       "   'from traitlets import (\\n',\n",
       "   '    Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError,\\n',\n",
       "   ')\\n',\n",
       "   'from IPython.utils.warn import warn\\n',\n",
       "   '\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '# Classes and functions\\n',\n",
       "   '#-----------------------------------------------------------------------------\\n',\n",
       "   '\\n',\n",
       "   '@undoc\\n',\n",
       "   'class DummyDB(object):\\n',\n",
       "   '    \"\"\"Dummy DB that will act as a black hole for history.\\n',\n",
       "   '    \\n',\n",
       "   '    Only used in the absence of sqlite\"\"\"\\n',\n",
       "   '    def execute(*args, **kwargs):\\n',\n",
       "   '        return []\\n',\n",
       "   '    \\n',\n",
       "   '    def commit(self, *args, **kwargs):\\n',\n",
       "   '        pass\\n',\n",
       "   '    \\n',\n",
       "   '    def __enter__(self, *args, **kwargs):\\n',\n",
       "   '        pass\\n',\n",
       "   '    \\n',\n",
       "   '    def __exit__(self, *args, **kwargs):\\n',\n",
       "   '        pass\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '@decorator\\n',\n",
       "   'def needs_sqlite(f, self, *a, **kw):\\n',\n",
       "   '    \"\"\"Decorator: return an empty list in the absence of sqlite.\"\"\"\\n',\n",
       "   '    if sqlite3 is None or not self.enabled:\\n',\n",
       "   '        return []\\n',\n",
       "   '    else:\\n',\n",
       "   '        return f(self, *a, **kw)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'if sqlite3 is not None:\\n',\n",
       "   '    DatabaseError = sqlite3.DatabaseError\\n',\n",
       "   '    OperationalError = sqlite3.OperationalError\\n',\n",
       "   'else:\\n',\n",
       "   '    @undoc\\n',\n",
       "   '    class DatabaseError(Exception):\\n',\n",
       "   '        \"Dummy exception when sqlite could not be imported. Should never occur.\"\\n',\n",
       "   '    \\n',\n",
       "   '    @undoc\\n',\n",
       "   '    class OperationalError(Exception):\\n',\n",
       "   '        \"Dummy exception when sqlite could not be imported. Should never occur.\"\\n',\n",
       "   '\\n',\n",
       "   '@decorator\\n',\n",
       "   'def catch_corrupt_db(f, self, *a, **kw):\\n',\n",
       "   '    \"\"\"A decorator which wraps HistoryAccessor method calls to catch errors from\\n',\n",
       "   '    a corrupt SQLite database, move the old database out of the way, and create\\n',\n",
       "   '    a new one.\\n',\n",
       "   '    \"\"\"\\n',\n",
       "   '    try:\\n',\n",
       "   '        return f(self, *a, **kw)\\n',\n",
       "   '    except (DatabaseError, OperationalError):\\n',\n",
       "   '        if os.path.isfile(self.hist_file):\\n',\n",
       "   '            # Try to move the file out of the way\\n',\n",
       "   '            base,ext = os.path.splitext(self.hist_file)\\n',\n",
       "   \"            newpath = base + '-corrupt' + ext\\n\",\n",
       "   '            os.rename(self.hist_file, newpath)\\n',\n",
       "   '            self.init_db()\\n',\n",
       "   '            print(\"ERROR! History file wasn\\'t a valid SQLite database.\",\\n',\n",
       "   '            \"It was moved to %s\" % newpath, \"and a new file created.\")\\n',\n",
       "   '            return []\\n',\n",
       "   '        \\n',\n",
       "   '        else:\\n',\n",
       "   '            # The hist_file is probably :memory: or something else.\\n',\n",
       "   '            raise\\n',\n",
       "   '        \\n',\n",
       "   'class HistoryAccessorBase(Configurable):\\n',\n",
       "   '    \"\"\"An abstract class for History Accessors \"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    def get_tail(self, n=10, raw=True, output=False, include_latest=False):\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    def search(self, pattern=\"*\", raw=True, search_raw=True,\\n',\n",
       "   '               output=False, n=None, unique=False):\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    def get_range(self, session, start=1, stop=None, raw=True,output=False):\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '    def get_range_by_str(self, rangestr, raw=True, output=False):\\n',\n",
       "   '        raise NotImplementedError\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class HistoryAccessor(HistoryAccessorBase):\\n',\n",
       "   '    \"\"\"Access the history database without adding to it.\\n',\n",
       "   '    \\n',\n",
       "   '    This is intended for use by standalone history tools. IPython shells use\\n',\n",
       "   '    HistoryManager, below, which is a subclass of this.\"\"\"\\n',\n",
       "   '\\n',\n",
       "   '    # String holding the path to the history file\\n',\n",
       "   '    hist_file = Unicode(config=True,\\n',\n",
       "   '        help=\"\"\"Path to file to use for SQLite history database.\\n',\n",
       "   '        \\n',\n",
       "   '        By default, IPython will put the history database in the IPython\\n',\n",
       "   '        profile directory.  If you would rather share one history among\\n',\n",
       "   '        profiles, you can set this value in each, so that they are consistent.\\n',\n",
       "   '        \\n',\n",
       "   '        Due to an issue with fcntl, SQLite is known to misbehave on some NFS\\n',\n",
       "   '        mounts.  If you see IPython hanging, try setting this to something on a\\n',\n",
       "   '        local disk, e.g::\\n',\n",
       "   '        \\n',\n",
       "   '            ipython --HistoryManager.hist_file=/tmp/ipython_hist.sqlite\\n',\n",
       "   '        \\n',\n",
       "   '        \"\"\")\\n',\n",
       "   '    \\n',\n",
       "   '    enabled = Bool(True, config=True,\\n',\n",
       "   '        help=\"\"\"enable the SQLite history\\n',\n",
       "   '        \\n',\n",
       "   '        set enabled=False to disable the SQLite history,\\n',\n",
       "   '        in which case there will be no stored history, no SQLite connection,\\n',\n",
       "   '        and no background saving thread.  This may be necessary in some\\n',\n",
       "   '        threaded environments where IPython is embedded.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '    \\n',\n",
       "   '    connection_options = Dict(config=True,\\n',\n",
       "   '        help=\"\"\"Options for configuring the SQLite connection\\n',\n",
       "   '        \\n',\n",
       "   '        These options are passed as keyword args to sqlite3.connect\\n',\n",
       "   '        when establishing database conenctions.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '    )\\n',\n",
       "   '\\n',\n",
       "   '    # The SQLite database\\n',\n",
       "   '    db = Any()\\n',\n",
       "   '    def _db_changed(self, name, old, new):\\n',\n",
       "   '        \"\"\"validate the db, since it can be an Instance of two different types\"\"\"\\n',\n",
       "   '        connection_types = (DummyDB,)\\n',\n",
       "   '        if sqlite3 is not None:\\n',\n",
       "   '            connection_types = (DummyDB, sqlite3.Connection)\\n',\n",
       "   '        if not isinstance(new, connection_types):\\n',\n",
       "   '            msg = \"%s.db must be sqlite3 Connection or DummyDB, not %r\" % \\\\\\n',\n",
       "   '                    (self.__class__.__name__, new)\\n',\n",
       "   '            raise TraitError(msg)\\n',\n",
       "   '    \\n',\n",
       "   \"    def __init__(self, profile='default', hist_file=u'', **traits):\\n\",\n",
       "   '        \"\"\"Create a new history accessor.\\n',\n",
       "   '        \\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        profile : str\\n',\n",
       "   '          The name of the profile from which to open history.\\n',\n",
       "   '        hist_file : str\\n',\n",
       "   '          Path to an SQLite history database stored by IPython. If specified,\\n',\n",
       "   '          hist_file overrides profile.\\n',\n",
       "   '        config : :class:`~traitlets.config.loader.Config`\\n',\n",
       "   '          Config object. hist_file can also be set through this.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        # We need a pointer back to the shell for various tasks.\\n',\n",
       "   '        super(HistoryAccessor, self).__init__(**traits)\\n',\n",
       "   '        # defer setting hist_file from kwarg until after init,\\n',\n",
       "   '        # otherwise the default kwarg value would clobber any value\\n',\n",
       "   '        # set by config\\n',\n",
       "   '        if hist_file:\\n',\n",
       "   '            self.hist_file = hist_file\\n',\n",
       "   '        \\n',\n",
       "   \"        if self.hist_file == u'':\\n\",\n",
       "   '            # No one has set the hist_file, yet.\\n',\n",
       "   '            self.hist_file = self._get_hist_file_name(profile)\\n',\n",
       "   '\\n',\n",
       "   '        if sqlite3 is None and self.enabled:\\n',\n",
       "   '            warn(\"IPython History requires SQLite, your history will not be saved\")\\n',\n",
       "   '            self.enabled = False\\n',\n",
       "   '        \\n',\n",
       "   '        self.init_db()\\n',\n",
       "   '    \\n',\n",
       "   \"    def _get_hist_file_name(self, profile='default'):\\n\",\n",
       "   '        \"\"\"Find the history file for the given profile name.\\n',\n",
       "   '        \\n',\n",
       "   \"        This is overridden by the HistoryManager subclass, to use the shell's\\n\",\n",
       "   '        active profile.\\n',\n",
       "   '        \\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        profile : str\\n',\n",
       "   '          The name of a profile which has a history file.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        return os.path.join(locate_profile(profile), 'history.sqlite')\\n\",\n",
       "   '    \\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def init_db(self):\\n',\n",
       "   '        \"\"\"Connect to the database, and create tables if necessary.\"\"\"\\n',\n",
       "   '        if not self.enabled:\\n',\n",
       "   '            self.db = DummyDB()\\n',\n",
       "   '            return\\n',\n",
       "   '        \\n',\n",
       "   '        # use detect_types so that timestamps return datetime objects\\n',\n",
       "   '        kwargs = dict(detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)\\n',\n",
       "   '        kwargs.update(self.connection_options)\\n',\n",
       "   '        self.db = sqlite3.connect(self.hist_file, **kwargs)\\n',\n",
       "   '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS sessions (session integer\\n',\n",
       "   '                        primary key autoincrement, start timestamp,\\n',\n",
       "   '                        end timestamp, num_cmds integer, remark text)\"\"\")\\n',\n",
       "   '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS history\\n',\n",
       "   '                (session integer, line integer, source text, source_raw text,\\n',\n",
       "   '                PRIMARY KEY (session, line))\"\"\")\\n',\n",
       "   \"        # Output history is optional, but ensure the table's there so it can be\\n\",\n",
       "   '        # enabled later.\\n',\n",
       "   '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS output_history\\n',\n",
       "   '                        (session integer, line integer, output text,\\n',\n",
       "   '                        PRIMARY KEY (session, line))\"\"\")\\n',\n",
       "   '        self.db.commit()\\n',\n",
       "   '\\n',\n",
       "   '    def writeout_cache(self):\\n',\n",
       "   '        \"\"\"Overridden by HistoryManager to dump the cache before certain\\n',\n",
       "   '        database lookups.\"\"\"\\n',\n",
       "   '        pass\\n',\n",
       "   '\\n',\n",
       "   '    ## -------------------------------\\n',\n",
       "   '    ## Methods for retrieving history:\\n',\n",
       "   '    ## -------------------------------\\n',\n",
       "   '    def _run_sql(self, sql, params, raw=True, output=False):\\n',\n",
       "   '        \"\"\"Prepares and runs an SQL query for the history database.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        sql : str\\n',\n",
       "   '          Any filtering expressions to go after SELECT ... FROM ...\\n',\n",
       "   '        params : tuple\\n',\n",
       "   '          Parameters passed to the SQL query (to replace \"?\")\\n',\n",
       "   '        raw, output : bool\\n',\n",
       "   '          See :meth:`get_range`\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        Tuples as :meth:`get_range`\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   \"        toget = 'source_raw' if raw else 'source'\\n\",\n",
       "   '        sqlfrom = \"history\"\\n',\n",
       "   '        if output:\\n',\n",
       "   '            sqlfrom = \"history LEFT JOIN output_history USING (session, line)\"\\n',\n",
       "   '            toget = \"history.%s, output_history.output\" % toget\\n',\n",
       "   '        cur = self.db.execute(\"SELECT session, line, %s FROM %s \" %\\\\\\n',\n",
       "   '                                (toget, sqlfrom) + sql, params)\\n',\n",
       "   '        if output:    # Regroup into 3-tuples, and parse JSON\\n',\n",
       "   '            return ((ses, lin, (inp, out)) for ses, lin, inp, out in cur)\\n',\n",
       "   '        return cur\\n',\n",
       "   '\\n',\n",
       "   '    @needs_sqlite\\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def get_session_info(self, session):\\n',\n",
       "   '        \"\"\"Get info about a session.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '\\n',\n",
       "   '        session : int\\n',\n",
       "   '            Session number to retrieve.\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        \\n',\n",
       "   '        session_id : int\\n',\n",
       "   '           Session ID number\\n',\n",
       "   '        start : datetime\\n',\n",
       "   '           Timestamp for the start of the session.\\n',\n",
       "   '        end : datetime\\n',\n",
       "   '           Timestamp for the end of the session, or None if IPython crashed.\\n',\n",
       "   '        num_cmds : int\\n',\n",
       "   '           Number of commands run, or None if IPython crashed.\\n',\n",
       "   '        remark : unicode\\n',\n",
       "   '           A manually set description.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        query = \"SELECT * from sessions where session == ?\"\\n',\n",
       "   '        return self.db.execute(query, (session,)).fetchone()\\n',\n",
       "   '\\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def get_last_session_id(self):\\n',\n",
       "   '        \"\"\"Get the last session ID currently in the database.\\n',\n",
       "   '        \\n',\n",
       "   '        Within IPython, this should be the same as the value stored in\\n',\n",
       "   '        :attr:`HistoryManager.session_number`.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        for record in self.get_tail(n=1, include_latest=True):\\n',\n",
       "   '            return record[0]\\n',\n",
       "   '\\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def get_tail(self, n=10, raw=True, output=False, include_latest=False):\\n',\n",
       "   '        \"\"\"Get the last n lines from the history database.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        n : int\\n',\n",
       "   '          The number of lines to get\\n',\n",
       "   '        raw, output : bool\\n',\n",
       "   '          See :meth:`get_range`\\n',\n",
       "   '        include_latest : bool\\n',\n",
       "   '          If False (default), n+1 lines are fetched, and the latest one\\n',\n",
       "   '          is discarded. This is intended to be used where the function\\n',\n",
       "   '          is called by a user command, which it should not return.\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        Tuples as :meth:`get_range`\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        self.writeout_cache()\\n',\n",
       "   '        if not include_latest:\\n',\n",
       "   '            n += 1\\n',\n",
       "   '        cur = self._run_sql(\"ORDER BY session DESC, line DESC LIMIT ?\",\\n',\n",
       "   '                                (n,), raw=raw, output=output)\\n',\n",
       "   '        if not include_latest:\\n',\n",
       "   '            return reversed(list(cur)[1:])\\n',\n",
       "   '        return reversed(list(cur))\\n',\n",
       "   '\\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def search(self, pattern=\"*\", raw=True, search_raw=True,\\n',\n",
       "   '               output=False, n=None, unique=False):\\n',\n",
       "   '        \"\"\"Search the database using unix glob-style matching (wildcards\\n',\n",
       "   '        * and ?).\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        pattern : str\\n',\n",
       "   '          The wildcarded pattern to match when searching\\n',\n",
       "   '        search_raw : bool\\n',\n",
       "   '          If True, search the raw input, otherwise, the parsed input\\n',\n",
       "   '        raw, output : bool\\n',\n",
       "   '          See :meth:`get_range`\\n',\n",
       "   '        n : None or int\\n',\n",
       "   '          If an integer is given, it defines the limit of\\n',\n",
       "   '          returned entries.\\n',\n",
       "   '        unique : bool\\n',\n",
       "   '          When it is true, return only unique entries.\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        Tuples as :meth:`get_range`\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        tosearch = \"source_raw\" if search_raw else \"source\"\\n',\n",
       "   '        if output:\\n',\n",
       "   '            tosearch = \"history.\" + tosearch\\n',\n",
       "   '        self.writeout_cache()\\n',\n",
       "   '        sqlform = \"WHERE %s GLOB ?\" % tosearch\\n',\n",
       "   '        params = (pattern,)\\n',\n",
       "   '        if unique:\\n',\n",
       "   \"            sqlform += ' GROUP BY {0}'.format(tosearch)\\n\",\n",
       "   '        if n is not None:\\n',\n",
       "   '            sqlform += \" ORDER BY session DESC, line DESC LIMIT ?\"\\n',\n",
       "   '            params += (n,)\\n',\n",
       "   '        elif unique:\\n',\n",
       "   '            sqlform += \" ORDER BY session, line\"\\n',\n",
       "   '        cur = self._run_sql(sqlform, params, raw=raw, output=output)\\n',\n",
       "   '        if n is not None:\\n',\n",
       "   '            return reversed(list(cur))\\n',\n",
       "   '        return cur\\n',\n",
       "   '    \\n',\n",
       "   '    @catch_corrupt_db\\n',\n",
       "   '    def get_range(self, session, start=1, stop=None, raw=True,output=False):\\n',\n",
       "   '        \"\"\"Retrieve input by session.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        session : int\\n',\n",
       "   '            Session number to retrieve.\\n',\n",
       "   '        start : int\\n',\n",
       "   '            First line to retrieve.\\n',\n",
       "   '        stop : int\\n',\n",
       "   '            End of line range (excluded from output itself). If None, retrieve\\n',\n",
       "   '            to the end of the session.\\n',\n",
       "   '        raw : bool\\n',\n",
       "   '            If True, return untranslated input\\n',\n",
       "   '        output : bool\\n',\n",
       "   \"            If True, attempt to include output. This will be 'real' Python\\n\",\n",
       "   '            objects for the current session, or text reprs from previous\\n',\n",
       "   '            sessions if db_log_output was enabled at the time. Where no output\\n',\n",
       "   '            is found, None is used.\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        entries\\n',\n",
       "   '          An iterator over the desired lines. Each line is a 3-tuple, either\\n',\n",
       "   '          (session, line, input) if output is False, or\\n',\n",
       "   '          (session, line, (input, output)) if output is True.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if stop:\\n',\n",
       "   '            lineclause = \"line >= ? AND line < ?\"\\n',\n",
       "   '            params = (session, start, stop)\\n',\n",
       "   '        else:\\n',\n",
       "   '            lineclause = \"line>=?\"\\n',\n",
       "   '            params = (session, start)\\n',\n",
       "   '\\n',\n",
       "   '        return self._run_sql(\"WHERE session==? AND %s\" % lineclause,\\n',\n",
       "   '                                    params, raw=raw, output=output)\\n',\n",
       "   '\\n',\n",
       "   '    def get_range_by_str(self, rangestr, raw=True, output=False):\\n',\n",
       "   '        \"\"\"Get lines of history from a string of ranges, as used by magic\\n',\n",
       "   '        commands %hist, %save, %macro, etc.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        rangestr : str\\n',\n",
       "   '          A string specifying ranges, e.g. \"5 ~2/1-4\". See\\n',\n",
       "   '          :func:`magic_history` for full details.\\n',\n",
       "   '        raw, output : bool\\n',\n",
       "   '          As :meth:`get_range`\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        Tuples as :meth:`get_range`\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        for sess, s, e in extract_hist_ranges(rangestr):\\n',\n",
       "   '            for line in self.get_range(sess, s, e, raw=raw, output=output):\\n',\n",
       "   '                yield line\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class HistoryManager(HistoryAccessor):\\n',\n",
       "   '    \"\"\"A class to organize all history-related functionality in one place.\\n',\n",
       "   '    \"\"\"\\n',\n",
       "   '    # Public interface\\n',\n",
       "   '\\n',\n",
       "   '    # An instance of the IPython shell we are attached to\\n',\n",
       "   \"    shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',\\n\",\n",
       "   '                     allow_none=True)\\n',\n",
       "   '    # Lists to hold processed and raw history. These start with a blank entry\\n',\n",
       "   '    # so that we can index them starting from 1\\n',\n",
       "   '    input_hist_parsed = List([\"\"])\\n',\n",
       "   '    input_hist_raw = List([\"\"])\\n',\n",
       "   '    # A list of directories visited during session\\n',\n",
       "   '    dir_hist = List()\\n',\n",
       "   '    def _dir_hist_default(self):\\n',\n",
       "   '        try:\\n',\n",
       "   '            return [py3compat.getcwd()]\\n',\n",
       "   '        except OSError:\\n',\n",
       "   '            return []\\n',\n",
       "   '\\n',\n",
       "   \"    # A dict of output history, keyed with ints from the shell's\\n\",\n",
       "   '    # execution count.\\n',\n",
       "   '    output_hist = Dict()\\n',\n",
       "   '    # The text/plain repr of outputs.\\n',\n",
       "   '    output_hist_reprs = Dict()\\n',\n",
       "   '\\n',\n",
       "   '    # The number of the current session in the history database\\n',\n",
       "   '    session_number = Integer()\\n',\n",
       "   '    \\n',\n",
       "   '    db_log_output = Bool(False, config=True,\\n',\n",
       "   '        help=\"Should the history database include output? (default: no)\"\\n',\n",
       "   '    )\\n',\n",
       "   '    db_cache_size = Integer(0, config=True,\\n',\n",
       "   '        help=\"Write to database every x commands (higher values save disk access & power).\\\\n\"\\n',\n",
       "   '        \"Values of 1 or less effectively disable caching.\"\\n',\n",
       "   '    )\\n',\n",
       "   '    # The input and output caches\\n',\n",
       "   '    db_input_cache = List()\\n',\n",
       "   '    db_output_cache = List()\\n',\n",
       "   '    \\n',\n",
       "   '    # History saving in separate thread\\n',\n",
       "   \"    save_thread = Instance('IPython.core.history.HistorySavingThread',\\n\",\n",
       "   '                           allow_none=True)\\n',\n",
       "   '    try:               # Event is a function returning an instance of _Event...\\n',\n",
       "   '        save_flag = Instance(threading._Event, allow_none=True)\\n',\n",
       "   \"    except AttributeError:         # ...until Python 3.3, when it's a class.\\n\",\n",
       "   '        save_flag = Instance(threading.Event, allow_none=True)\\n',\n",
       "   '    \\n',\n",
       "   '    # Private interface\\n',\n",
       "   '    # Variables used to store the three last inputs from the user.  On each new\\n',\n",
       "   \"    # history update, we populate the user's namespace with these, shifted as\\n\",\n",
       "   '    # necessary.\\n',\n",
       "   \"    _i00 = Unicode(u'')\\n\",\n",
       "   \"    _i = Unicode(u'')\\n\",\n",
       "   \"    _ii = Unicode(u'')\\n\",\n",
       "   \"    _iii = Unicode(u'')\\n\",\n",
       "   '\\n',\n",
       "   \"    # A regex matching all forms of the exit command, so that we don't store\\n\",\n",
       "   \"    # them in the history (it's annoying to rewind the first entry and land on\\n\",\n",
       "   '    # an exit call).\\n',\n",
       "   '    _exit_re = re.compile(r\"(exit|quit)(\\\\s*\\\\(.*\\\\))?$\")\\n',\n",
       "   '\\n',\n",
       "   '    def __init__(self, shell=None, config=None, **traits):\\n',\n",
       "   '        \"\"\"Create a new history manager associated with a shell instance.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        # We need a pointer back to the shell for various tasks.\\n',\n",
       "   '        super(HistoryManager, self).__init__(shell=shell, config=config,\\n',\n",
       "   '            **traits)\\n',\n",
       "   '        self.save_flag = threading.Event()\\n',\n",
       "   '        self.db_input_cache_lock = threading.Lock()\\n',\n",
       "   '        self.db_output_cache_lock = threading.Lock()\\n',\n",
       "   '        \\n',\n",
       "   '        try:\\n',\n",
       "   '            self.new_session()\\n',\n",
       "   '        except OperationalError:\\n',\n",
       "   '            self.log.error(\"Failed to create history session in %s. History will not be saved.\",\\n',\n",
       "   '                self.hist_file, exc_info=True)\\n',\n",
       "   \"            self.hist_file = ':memory:'\\n\",\n",
       "   '        \\n',\n",
       "   \"        if self.enabled and self.hist_file != ':memory:':\\n\",\n",
       "   '            self.save_thread = HistorySavingThread(self)\\n',\n",
       "   '            self.save_thread.start()\\n',\n",
       "   '\\n',\n",
       "   '    def _get_hist_file_name(self, profile=None):\\n',\n",
       "   '        \"\"\"Get default history file name based on the Shell\\'s profile.\\n',\n",
       "   '        \\n',\n",
       "   '        The profile parameter is ignored, but must exist for compatibility with\\n',\n",
       "   '        the parent class.\"\"\"\\n',\n",
       "   '        profile_dir = self.shell.profile_dir.location\\n',\n",
       "   \"        return os.path.join(profile_dir, 'history.sqlite')\\n\",\n",
       "   '    \\n',\n",
       "   '    @needs_sqlite\\n',\n",
       "   '    def new_session(self, conn=None):\\n',\n",
       "   '        \"\"\"Get a new session number.\"\"\"\\n',\n",
       "   '        if conn is None:\\n',\n",
       "   '            conn = self.db\\n',\n",
       "   '        \\n',\n",
       "   '        with conn:\\n',\n",
       "   '            cur = conn.execute(\"\"\"INSERT INTO sessions VALUES (NULL, ?, NULL,\\n',\n",
       "   '                            NULL, \"\") \"\"\", (datetime.datetime.now(),))\\n',\n",
       "   '            self.session_number = cur.lastrowid\\n',\n",
       "   '            \\n',\n",
       "   '    def end_session(self):\\n',\n",
       "   '        \"\"\"Close the database session, filling in the end time and line count.\"\"\"\\n',\n",
       "   '        self.writeout_cache()\\n',\n",
       "   '        with self.db:\\n',\n",
       "   '            self.db.execute(\"\"\"UPDATE sessions SET end=?, num_cmds=? WHERE\\n',\n",
       "   '                            session==?\"\"\", (datetime.datetime.now(),\\n',\n",
       "   '                            len(self.input_hist_parsed)-1, self.session_number))\\n',\n",
       "   '        self.session_number = 0\\n',\n",
       "   '                            \\n',\n",
       "   '    def name_session(self, name):\\n',\n",
       "   '        \"\"\"Give the current session a name in the history database.\"\"\"\\n',\n",
       "   '        with self.db:\\n',\n",
       "   '            self.db.execute(\"UPDATE sessions SET remark=? WHERE session==?\",\\n',\n",
       "   '                            (name, self.session_number))\\n',\n",
       "   '                            \\n',\n",
       "   '    def reset(self, new_session=True):\\n',\n",
       "   '        \"\"\"Clear the session history, releasing all object references, and\\n',\n",
       "   '        optionally open a new session.\"\"\"\\n',\n",
       "   '        self.output_hist.clear()\\n',\n",
       "   \"        # The directory history can't be completely empty\\n\",\n",
       "   '        self.dir_hist[:] = [py3compat.getcwd()]\\n',\n",
       "   '        \\n',\n",
       "   '        if new_session:\\n',\n",
       "   '            if self.session_number:\\n',\n",
       "   '                self.end_session()\\n',\n",
       "   '            self.input_hist_parsed[:] = [\"\"]\\n',\n",
       "   '            self.input_hist_raw[:] = [\"\"]\\n',\n",
       "   '            self.new_session()\\n',\n",
       "   '\\n',\n",
       "   '    # ------------------------------\\n',\n",
       "   '    # Methods for retrieving history\\n',\n",
       "   '    # ------------------------------\\n',\n",
       "   '    def get_session_info(self, session=0):\\n',\n",
       "   '        \"\"\"Get info about a session.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '\\n',\n",
       "   '        session : int\\n',\n",
       "   '            Session number to retrieve. The current session is 0, and negative\\n',\n",
       "   '            numbers count back from current session, so -1 is the previous session.\\n',\n",
       "   '\\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        \\n',\n",
       "   '        session_id : int\\n',\n",
       "   '           Session ID number\\n',\n",
       "   '        start : datetime\\n',\n",
       "   '           Timestamp for the start of the session.\\n',\n",
       "   '        end : datetime\\n',\n",
       "   '           Timestamp for the end of the session, or None if IPython crashed.\\n',\n",
       "   '        num_cmds : int\\n',\n",
       "   '           Number of commands run, or None if IPython crashed.\\n',\n",
       "   '        remark : unicode\\n',\n",
       "   '           A manually set description.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if session <= 0:\\n',\n",
       "   '            session += self.session_number\\n',\n",
       "   '\\n',\n",
       "   '        return super(HistoryManager, self).get_session_info(session=session)\\n',\n",
       "   '\\n',\n",
       "   '    def _get_range_session(self, start=1, stop=None, raw=True, output=False):\\n',\n",
       "   '        \"\"\"Get input and output history from the current session. Called by\\n',\n",
       "   '        get_range, and takes similar parameters.\"\"\"\\n',\n",
       "   '        input_hist = self.input_hist_raw if raw else self.input_hist_parsed\\n',\n",
       "   '            \\n',\n",
       "   '        n = len(input_hist)\\n',\n",
       "   '        if start < 0:\\n',\n",
       "   '            start += n\\n',\n",
       "   '        if not stop or (stop > n):\\n',\n",
       "   '            stop = n\\n',\n",
       "   '        elif stop < 0:\\n',\n",
       "   '            stop += n\\n',\n",
       "   '        \\n',\n",
       "   '        for i in range(start, stop):\\n',\n",
       "   '            if output:\\n',\n",
       "   '                line = (input_hist[i], self.output_hist_reprs.get(i))\\n',\n",
       "   '            else:\\n',\n",
       "   '                line = input_hist[i]\\n',\n",
       "   '            yield (0, i, line)\\n',\n",
       "   '    \\n',\n",
       "   '    def get_range(self, session=0, start=1, stop=None, raw=True,output=False):\\n',\n",
       "   '        \"\"\"Retrieve input by session.\\n',\n",
       "   '        \\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        session : int\\n',\n",
       "   '            Session number to retrieve. The current session is 0, and negative\\n',\n",
       "   '            numbers count back from current session, so -1 is previous session.\\n',\n",
       "   '        start : int\\n',\n",
       "   '            First line to retrieve.\\n',\n",
       "   '        stop : int\\n',\n",
       "   '            End of line range (excluded from output itself). If None, retrieve\\n',\n",
       "   '            to the end of the session.\\n',\n",
       "   '        raw : bool\\n',\n",
       "   '            If True, return untranslated input\\n',\n",
       "   '        output : bool\\n',\n",
       "   \"            If True, attempt to include output. This will be 'real' Python\\n\",\n",
       "   '            objects for the current session, or text reprs from previous\\n',\n",
       "   '            sessions if db_log_output was enabled at the time. Where no output\\n',\n",
       "   '            is found, None is used.\\n',\n",
       "   '            \\n',\n",
       "   '        Returns\\n',\n",
       "   '        -------\\n',\n",
       "   '        entries\\n',\n",
       "   '          An iterator over the desired lines. Each line is a 3-tuple, either\\n',\n",
       "   '          (session, line, input) if output is False, or\\n',\n",
       "   '          (session, line, (input, output)) if output is True.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if session <= 0:\\n',\n",
       "   '            session += self.session_number\\n',\n",
       "   '        if session==self.session_number:          # Current session\\n',\n",
       "   '            return self._get_range_session(start, stop, raw, output)\\n',\n",
       "   '        return super(HistoryManager, self).get_range(session, start, stop, raw,\\n',\n",
       "   '                                                     output)\\n',\n",
       "   '\\n',\n",
       "   '    ## ----------------------------\\n',\n",
       "   '    ## Methods for storing history:\\n',\n",
       "   '    ## ----------------------------\\n',\n",
       "   '    def store_inputs(self, line_num, source, source_raw=None):\\n',\n",
       "   '        \"\"\"Store source and raw input in history and create input cache\\n',\n",
       "   '        variables ``_i*``.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        line_num : int\\n',\n",
       "   '          The prompt number of this input.\\n',\n",
       "   '\\n',\n",
       "   '        source : str\\n',\n",
       "   '          Python input.\\n',\n",
       "   '\\n',\n",
       "   '        source_raw : str, optional\\n',\n",
       "   '          If given, this is the raw input without any IPython transformations\\n',\n",
       "   '          applied to it.  If not given, ``source`` is used.\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if source_raw is None:\\n',\n",
       "   '            source_raw = source\\n',\n",
       "   \"        source = source.rstrip('\\\\n')\\n\",\n",
       "   \"        source_raw = source_raw.rstrip('\\\\n')\\n\",\n",
       "   '\\n',\n",
       "   '        # do not store exit/quit commands\\n',\n",
       "   '        if self._exit_re.match(source_raw.strip()):\\n',\n",
       "   '            return\\n',\n",
       "   '\\n',\n",
       "   '        self.input_hist_parsed.append(source)\\n',\n",
       "   '        self.input_hist_raw.append(source_raw)\\n',\n",
       "   '\\n',\n",
       "   '        with self.db_input_cache_lock:\\n',\n",
       "   '            self.db_input_cache.append((line_num, source, source_raw))\\n',\n",
       "   '            # Trigger to flush cache and write to DB.\\n',\n",
       "   '            if len(self.db_input_cache) >= self.db_cache_size:\\n',\n",
       "   '                self.save_flag.set()\\n',\n",
       "   '\\n',\n",
       "   '        # update the auto _i variables\\n',\n",
       "   '        self._iii = self._ii\\n',\n",
       "   '        self._ii = self._i\\n',\n",
       "   '        self._i = self._i00\\n',\n",
       "   '        self._i00 = source_raw\\n',\n",
       "   '\\n',\n",
       "   '        # hackish access to user namespace to create _i1,_i2... dynamically\\n',\n",
       "   \"        new_i = '_i%s' % line_num\\n\",\n",
       "   \"        to_main = {'_i': self._i,\\n\",\n",
       "   \"                   '_ii': self._ii,\\n\",\n",
       "   \"                   '_iii': self._iii,\\n\",\n",
       "   '                   new_i : self._i00 }\\n',\n",
       "   '        \\n',\n",
       "   '        if self.shell is not None:\\n',\n",
       "   '            self.shell.push(to_main, interactive=False)\\n',\n",
       "   '\\n',\n",
       "   '    def store_output(self, line_num):\\n',\n",
       "   '        \"\"\"If database output logging is enabled, this saves all the\\n',\n",
       "   \"        outputs from the indicated prompt number to the database. It's\\n\",\n",
       "   '        called by run_cell after code has been executed.\\n',\n",
       "   '\\n',\n",
       "   '        Parameters\\n',\n",
       "   '        ----------\\n',\n",
       "   '        line_num : int\\n',\n",
       "   '          The line number from which to save outputs\\n',\n",
       "   '        \"\"\"\\n',\n",
       "   '        if (not self.db_log_output) or (line_num not in self.output_hist_reprs):\\n',\n",
       "   '            return\\n',\n",
       "   '        output = self.output_hist_reprs[line_num]\\n',\n",
       "   '\\n',\n",
       "   '        with self.db_output_cache_lock:\\n',\n",
       "   '            self.db_output_cache.append((line_num, output))\\n',\n",
       "   '        if self.db_cache_size <= 1:\\n',\n",
       "   '            self.save_flag.set()\\n',\n",
       "   '\\n',\n",
       "   '    def _writeout_input_cache(self, conn):\\n',\n",
       "   '        with conn:\\n',\n",
       "   '            for line in self.db_input_cache:\\n',\n",
       "   '                conn.execute(\"INSERT INTO history VALUES (?, ?, ?, ?)\",\\n',\n",
       "   '                                (self.session_number,)+line)\\n',\n",
       "   '\\n',\n",
       "   '    def _writeout_output_cache(self, conn):\\n',\n",
       "   '        with conn:\\n',\n",
       "   '            for line in self.db_output_cache:\\n',\n",
       "   '                conn.execute(\"INSERT INTO output_history VALUES (?, ?, ?)\",\\n',\n",
       "   '                                (self.session_number,)+line)\\n',\n",
       "   '\\n',\n",
       "   '    @needs_sqlite\\n',\n",
       "   '    def writeout_cache(self, conn=None):\\n',\n",
       "   '        \"\"\"Write any entries in the cache to the database.\"\"\"\\n',\n",
       "   '        if conn is None:\\n',\n",
       "   '            conn = self.db\\n',\n",
       "   '\\n',\n",
       "   '        with self.db_input_cache_lock:\\n',\n",
       "   '            try:\\n',\n",
       "   '                self._writeout_input_cache(conn)\\n',\n",
       "   '            except sqlite3.IntegrityError:\\n',\n",
       "   '                self.new_session(conn)\\n',\n",
       "   '                print(\"ERROR! Session/line number was not unique in\",\\n',\n",
       "   '                      \"database. History logging moved to new session\",\\n',\n",
       "   '                                                self.session_number)\\n',\n",
       "   '                try:\\n',\n",
       "   \"                    # Try writing to the new session. If this fails, don't\\n\",\n",
       "   '                    # recurse\\n',\n",
       "   '                    self._writeout_input_cache(conn)\\n',\n",
       "   '                except sqlite3.IntegrityError:\\n',\n",
       "   '                    pass\\n',\n",
       "   '            finally:\\n',\n",
       "   '                self.db_input_cache = []\\n',\n",
       "   '\\n',\n",
       "   '        with self.db_output_cache_lock:\\n',\n",
       "   '            try:\\n',\n",
       "   '                self._writeout_output_cache(conn)\\n',\n",
       "   '            except sqlite3.IntegrityError:\\n',\n",
       "   '                print(\"!! Session/line number for output was not unique\",\\n',\n",
       "   '                      \"in database. Output will not be stored.\")\\n',\n",
       "   '            finally:\\n',\n",
       "   '                self.db_output_cache = []\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'class HistorySavingThread(threading.Thread):\\n',\n",
       "   '    \"\"\"This thread takes care of writing history to the database, so that\\n',\n",
       "   \"    the UI isn't held up while that happens.\\n\",\n",
       "   '\\n',\n",
       "   \"    It waits for the HistoryManager's save_flag to be set, then writes out\\n\",\n",
       "   '    the history cache. The main thread is responsible for setting the flag when\\n',\n",
       "   '    the cache size reaches a defined threshold.\"\"\"\\n',\n",
       "   '    daemon = True\\n',\n",
       "   '    stop_now = False\\n',\n",
       "   '    enabled = True\\n',\n",
       "   '    def __init__(self, history_manager):\\n',\n",
       "   '        super(HistorySavingThread, self).__init__(name=\"IPythonHistorySavingThread\")\\n',\n",
       "   '        self.history_manager = history_manager\\n',\n",
       "   '        self.enabled = history_manager.enabled\\n',\n",
       "   '        atexit.register(self.stop)\\n',\n",
       "   '\\n',\n",
       "   '    @needs_sqlite\\n',\n",
       "   '    def run(self):\\n',\n",
       "   '        # We need a separate db connection per thread:\\n',\n",
       "   '        try:\\n',\n",
       "   '            self.db = sqlite3.connect(self.history_manager.hist_file,\\n',\n",
       "   '                            **self.history_manager.connection_options\\n',\n",
       "   '            )\\n',\n",
       "   '            while True:\\n',\n",
       "   '                self.history_manager.save_flag.wait()\\n',\n",
       "   '                if self.stop_now:\\n',\n",
       "   '                    self.db.close()\\n',\n",
       "   '                    return\\n',\n",
       "   '                self.history_manager.save_flag.clear()\\n',\n",
       "   '                self.history_manager.writeout_cache(self.db)\\n',\n",
       "   '        except Exception as e:\\n',\n",
       "   '            print((\"The history saving thread hit an unexpected error (%s).\"\\n',\n",
       "   '                   \"History will not be written to the database.\") % repr(e))\\n',\n",
       "   '\\n',\n",
       "   '    def stop(self):\\n',\n",
       "   '        \"\"\"This can be called from the main thread to safely stop this thread.\\n',\n",
       "   '\\n',\n",
       "   '        Note that it does not attempt to write out remaining history before\\n',\n",
       "   \"        exiting. That should be done by calling the HistoryManager's\\n\",\n",
       "   '        end_session method.\"\"\"\\n',\n",
       "   '        self.stop_now = True\\n',\n",
       "   '        self.history_manager.save_flag.set()\\n',\n",
       "   '        self.join()\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   '# To match, e.g. ~5/8-~2/3\\n',\n",
       "   'range_re = re.compile(r\"\"\"\\n',\n",
       "   '((?P<startsess>~?\\\\d+)/)?\\n',\n",
       "   '(?P<start>\\\\d+)?\\n',\n",
       "   '((?P<sep>[\\\\-:])\\n',\n",
       "   ' ((?P<endsess>~?\\\\d+)/)?\\n',\n",
       "   ' (?P<end>\\\\d+))?\\n',\n",
       "   '$\"\"\", re.VERBOSE)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'def extract_hist_ranges(ranges_str):\\n',\n",
       "   '    \"\"\"Turn a string of history ranges into 3-tuples of (session, start, stop).\\n',\n",
       "   '\\n',\n",
       "   '    Examples\\n',\n",
       "   '    --------\\n',\n",
       "   '    >>> list(extract_hist_ranges(\"~8/5-~7/4 2\"))\\n',\n",
       "   '    [(-8, 5, None), (-7, 1, 5), (0, 2, 3)]\\n',\n",
       "   '    \"\"\"\\n',\n",
       "   '    for range_str in ranges_str.split():\\n',\n",
       "   '        rmatch = range_re.match(range_str)\\n',\n",
       "   '        if not rmatch:\\n',\n",
       "   '            continue\\n',\n",
       "   '        start = rmatch.group(\"start\")\\n',\n",
       "   '        if start:\\n',\n",
       "   '            start = int(start)\\n',\n",
       "   '            end = rmatch.group(\"end\")\\n',\n",
       "   '            # If no end specified, get (a, a + 1)\\n',\n",
       "   '            end = int(end) if end else start + 1\\n',\n",
       "   '        else:  # start not specified\\n',\n",
       "   \"            if not rmatch.group('startsess'):  # no startsess\\n\",\n",
       "   '                continue\\n',\n",
       "   '            start = 1\\n',\n",
       "   '            end = None  # provide the entire session hist\\n',\n",
       "   '\\n',\n",
       "   '        if rmatch.group(\"sep\") == \"-\":       # 1-3 == 1:4 --> [1, 2, 3]\\n',\n",
       "   '            end += 1\\n',\n",
       "   '        startsess = rmatch.group(\"startsess\") or \"0\"\\n',\n",
       "   '        endsess = rmatch.group(\"endsess\") or startsess\\n',\n",
       "   '        startsess = int(startsess.replace(\"~\",\"-\"))\\n',\n",
       "   '        endsess = int(endsess.replace(\"~\",\"-\"))\\n',\n",
       "   '        assert endsess >= startsess, \"start session must be earlier than end session\"\\n',\n",
       "   '\\n',\n",
       "   '        if endsess == startsess:\\n',\n",
       "   '            yield (startsess, start, end)\\n',\n",
       "   '            continue\\n',\n",
       "   '        # Multiple sessions in one range:\\n',\n",
       "   '        yield (startsess, start, None)\\n',\n",
       "   '        for sess in range(startsess+1, endsess):\\n',\n",
       "   '            yield (sess, 1, None)\\n',\n",
       "   '        yield (endsess, 1, end)\\n',\n",
       "   '\\n',\n",
       "   '\\n',\n",
       "   'def _format_lineno(session, line):\\n',\n",
       "   '    \"\"\"Helper function to format line numbers properly.\"\"\"\\n',\n",
       "   '    if session == 0:\\n',\n",
       "   '        return str(line)\\n',\n",
       "   '    return \"%s#%s\" % (session, line)\\n',\n",
       "   '\\n',\n",
       "   '\\n'],\n",
       "  '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/history.py'),\n",
       " {'_i': 'import gc\\ngc.garbage',\n",
       "  '_i00': 'gc.get_objects()',\n",
       "  '_ii': 'import gc\\ngc',\n",
       "  '_iii': 'import gc\\nпс',\n",
       "  'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'connection_options': {},\n",
       "  'db': <sqlite3.Connection at 0x7f51c12c0e30>,\n",
       "  'db_cache_size': 0,\n",
       "  'db_input_cache': [],\n",
       "  'db_log_output': False,\n",
       "  'db_output_cache': [],\n",
       "  'dir_hist': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "  'enabled': True,\n",
       "  'hist_file': '/home/pasha/.ipython/profile_default/history.sqlite',\n",
       "  'input_hist_parsed': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  'input_hist_raw': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  'output_hist': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "  'output_hist_reprs': {14: '3',\n",
       "   15: '3',\n",
       "   19: \"<module 'gc' (built-in)>\",\n",
       "   20: '[]'},\n",
       "  'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "  'save_flag': <threading.Event at 0x7f51c016e0f0>,\n",
       "  'save_thread': <HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>,\n",
       "  'session_number': 291,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [<weakref at 0x7f51c017b908; to 'sqlite3.Statement' at 0x7f51c016e0a0>,\n",
       "  <weakref at 0x7f51c017b818; to 'sqlite3.Statement' at 0x7f51c016e110>,\n",
       "  <weakref at 0x7f51c017b8b8; to 'sqlite3.Statement' at 0x7f51c016e730>,\n",
       "  <weakref at 0x7f51c017b9a8; to 'sqlite3.Statement' at 0x7f51c016e810>],\n",
       " [<weakref at 0x7f51c017b728; dead>,\n",
       "  <weakref at 0x7f51c017b7c8; dead>,\n",
       "  <weakref at 0x7f51c017b868; dead>,\n",
       "  <weakref at 0x7f51c017b958; dead>],\n",
       " <weakref at 0x7f51c017b728; dead>,\n",
       " <weakref at 0x7f51c017b908; to 'sqlite3.Statement' at 0x7f51c016e0a0>,\n",
       " {('CREATE TABLE IF NOT EXISTS history\\n                (session integer, line integer, source text, source_raw text,\\n                PRIMARY KEY (session, line))',): <sqlite3Node at 0x7f51c016e068>,\n",
       "  ('CREATE TABLE IF NOT EXISTS output_history\\n                        (session integer, line integer, output text,\\n                        PRIMARY KEY (session, line))',): <sqlite3Node at 0x7f51c016e768>,\n",
       "  ('CREATE TABLE IF NOT EXISTS sessions (session integer\\n                        primary key autoincrement, start timestamp,\\n                        end timestamp, num_cmds integer, remark text)',): <sqlite3Node at 0x7f51c016e030>,\n",
       "  ('INSERT INTO sessions VALUES (NULL, ?, NULL,\\n                            NULL, \"\") ',): <sqlite3Node at 0x7f51c016e848>},\n",
       " <weakref at 0x7f51c017b7c8; dead>,\n",
       " <weakref at 0x7f51c017b818; to 'sqlite3.Statement' at 0x7f51c016e110>,\n",
       " <weakref at 0x7f51c017b868; dead>,\n",
       " <weakref at 0x7f51c017b8b8; to 'sqlite3.Statement' at 0x7f51c016e730>,\n",
       " <threading.Event at 0x7f51c016e0f0>,\n",
       " {'_cond': <Condition(<_thread.lock object at 0x7f51c12898a0>, 1)>,\n",
       "  '_flag': False},\n",
       " <weakref at 0x7f51c017b958; dead>,\n",
       " <weakref at 0x7f51c017b9a8; to 'sqlite3.Statement' at 0x7f51c016e810>,\n",
       " <HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>,\n",
       " {'_args': (),\n",
       "  '_daemonic': False,\n",
       "  '_ident': 139988989622016,\n",
       "  '_initialized': True,\n",
       "  '_is_stopped': False,\n",
       "  '_kwargs': {},\n",
       "  '_name': 'IPythonHistorySavingThread',\n",
       "  '_started': <threading.Event at 0x7f51c016e898>,\n",
       "  '_stderr': <ipykernel.iostream.OutStream at 0x7f51c1221b38>,\n",
       "  '_target': None,\n",
       "  '_tstate_lock': <_thread.lock at 0x7f51c1289af8>,\n",
       "  'db': <sqlite3.Connection at 0x7f51c12c0c70>,\n",
       "  'enabled': True,\n",
       "  'history_manager': <IPython.core.history.HistoryManager at 0x7f51c1221710>},\n",
       " <threading.Event at 0x7f51c016e898>,\n",
       " {'_cond': <Condition(<_thread.lock object at 0x7f51c12899e0>, 0)>,\n",
       "  '_flag': True},\n",
       " <weakref at 0x7f51c017ba48; to 'HistorySavingThread' at 0x7f51c016e7f0>,\n",
       " <bound method HistorySavingThread.stop of <HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>>,\n",
       " <bound method HistorySavingThread._bootstrap of <HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>>,\n",
       " (<HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>,),\n",
       " <frame at 0x7f51c017f048>,\n",
       " <frame at 0x7f51a40008d8>,\n",
       " <weakref at 0x7f51c017ba98; to '_thread.lock' at 0x7f51c1289af8>,\n",
       " <frame at 0x7f51c11fc3b8>,\n",
       " <frame at 0x7f51c11fd5d0>,\n",
       " (<HistorySavingThread(IPythonHistorySavingThread, started 139988989622016)>,),\n",
       " <frame at 0x7f51a4000f58>,\n",
       " <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       " {'_checkers': [<EmacsChecker(priority=100, enabled=False)>,\n",
       "   <MacroChecker(priority=250, enabled=True)>,\n",
       "   <IPyAutocallChecker(priority=300, enabled=True)>,\n",
       "   <AssignmentChecker(priority=600, enabled=True)>,\n",
       "   <AutoMagicChecker(priority=700, enabled=True)>,\n",
       "   <PythonOpsChecker(priority=900, enabled=True)>,\n",
       "   <AutocallChecker(priority=1000, enabled=True)>],\n",
       "  '_cross_validation_lock': False,\n",
       "  '_esc_handlers': {'%': <IPython.core.prefilter.MagicHandler at 0x7f51c016eac8>,\n",
       "   ',': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "   '/': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "   ';': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>},\n",
       "  '_handlers': {'auto': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "   'emacs': <IPython.core.prefilter.EmacsHandler at 0x7f51c016eb70>,\n",
       "   'macro': <IPython.core.prefilter.MacroHandler at 0x7f51c016ea90>,\n",
       "   'magic': <IPython.core.prefilter.MagicHandler at 0x7f51c016eac8>,\n",
       "   'normal': <IPython.core.prefilter.PrefilterHandler at 0x7f51c016ea20>},\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'multi_line_specials': True,\n",
       "   'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       "  '_transformers': []},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'multi_line_specials': True,\n",
       "  'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [],\n",
       " {'auto': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "  'emacs': <IPython.core.prefilter.EmacsHandler at 0x7f51c016eb70>,\n",
       "  'macro': <IPython.core.prefilter.MacroHandler at 0x7f51c016ea90>,\n",
       "  'magic': <IPython.core.prefilter.MagicHandler at 0x7f51c016eac8>,\n",
       "  'normal': <IPython.core.prefilter.PrefilterHandler at 0x7f51c016ea20>},\n",
       " <IPython.core.prefilter.MacroHandler at 0x7f51c016ea90>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'esc_strings': [],\n",
       "   'handler_name': 'macro',\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'esc_strings': [],\n",
       "  'handler_name': 'macro',\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [],\n",
       " <IPython.core.prefilter.MagicHandler at 0x7f51c016eac8>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'esc_strings': ['%'],\n",
       "   'handler_name': 'magic',\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'esc_strings': ['%'],\n",
       "  'handler_name': 'magic',\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " ['%'],\n",
       " {'%': <IPython.core.prefilter.MagicHandler at 0x7f51c016eac8>,\n",
       "  ',': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "  '/': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       "  ';': <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>},\n",
       " <IPython.core.prefilter.AutoHandler at 0x7f51c016eb38>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'esc_strings': ['/', ',', ';'],\n",
       "   'handler_name': 'auto',\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'esc_strings': ['/', ',', ';'],\n",
       "  'handler_name': 'auto',\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " ['/', ',', ';'],\n",
       " <IPython.core.prefilter.EmacsHandler at 0x7f51c016eb70>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'esc_strings': [],\n",
       "   'handler_name': 'emacs',\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'esc_strings': [],\n",
       "  'handler_name': 'emacs',\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [],\n",
       " [<EmacsChecker(priority=100, enabled=False)>,\n",
       "  <MacroChecker(priority=250, enabled=True)>,\n",
       "  <IPyAutocallChecker(priority=300, enabled=True)>,\n",
       "  <AssignmentChecker(priority=600, enabled=True)>,\n",
       "  <AutoMagicChecker(priority=700, enabled=True)>,\n",
       "  <PythonOpsChecker(priority=900, enabled=True)>,\n",
       "  <AutocallChecker(priority=1000, enabled=True)>],\n",
       " <EmacsChecker(priority=100, enabled=False)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': False,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 100,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': False,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 100,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <MacroChecker(priority=250, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 250,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 250,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <bound method IOPubThread._thread_main of <ipykernel.iostream.IOPubThread object at 0x7f51c124be48>>,\n",
       " <Condition(<_thread.lock object at 0x7f51c125c3a0>, 0)>,\n",
       " [],\n",
       " [],\n",
       " <logging.PercentStyle at 0x7f51c1221d68>,\n",
       " (<cell at 0x7f51c1284588: weakref object at 0x7f51c12416d8>,),\n",
       " <zmq.sugar.context.Context at 0x7f51c11ee2e8>,\n",
       " <Condition(<_thread.lock object at 0x7f51c1289490>, 0)>,\n",
       " ModuleSpec(name='faulthandler', loader=<class '_frozen_importlib.BuiltinImporter'>, origin='built-in'),\n",
       " (<cell at 0x7f51c1284a98: builtin_function_or_method object at 0x7f51c1232cc8>,),\n",
       " (<cell at 0x7f51c1284ac8: builtin_function_or_method object at 0x7f51c122ee48>,),\n",
       " <zmq.eventloop.ioloop.ZMQPoller at 0x7f51c1221438>,\n",
       " <_io.FileIO name=29 mode='rb'>,\n",
       " (29, <function tornado.stack_context.wrap.<locals>.null_wrapper>),\n",
       " [],\n",
       " deque([]),\n",
       " <function lock.acquire>,\n",
       " <function lock.acquire>,\n",
       " <function lock.acquire>,\n",
       " <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       " [],\n",
       " deque([]),\n",
       " <function lock.acquire>,\n",
       " <function lock.acquire>,\n",
       " <function lock.acquire>,\n",
       " <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " ['\"\"\"Base class for a kernel that talks to frontends over 0MQ.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '# Copyright (c) IPython Development Team.\\n',\n",
       "  '# Distributed under the terms of the Modified BSD License.\\n',\n",
       "  '\\n',\n",
       "  'from __future__ import print_function\\n',\n",
       "  '\\n',\n",
       "  'import sys\\n',\n",
       "  'import time\\n',\n",
       "  'import logging\\n',\n",
       "  'import uuid\\n',\n",
       "  '\\n',\n",
       "  'from datetime import datetime\\n',\n",
       "  'from signal import (\\n',\n",
       "  '        signal, default_int_handler, SIGINT\\n',\n",
       "  ')\\n',\n",
       "  '\\n',\n",
       "  'import zmq\\n',\n",
       "  'from zmq.eventloop import ioloop\\n',\n",
       "  'from zmq.eventloop.zmqstream import ZMQStream\\n',\n",
       "  '\\n',\n",
       "  'from traitlets.config.configurable import SingletonConfigurable\\n',\n",
       "  'from IPython.core.error import StdinNotImplementedError\\n',\n",
       "  'from ipython_genutils import py3compat\\n',\n",
       "  'from ipython_genutils.py3compat import unicode_type, string_types\\n',\n",
       "  'from ipykernel.jsonutil import json_clean\\n',\n",
       "  'from traitlets import (\\n',\n",
       "  '    Any, Instance, Float, Dict, List, Set, Integer, Unicode, Bool,\\n',\n",
       "  ')\\n',\n",
       "  '\\n',\n",
       "  'from jupyter_client.session import Session\\n',\n",
       "  '\\n',\n",
       "  'from ._version import kernel_protocol_version\\n',\n",
       "  '\\n',\n",
       "  'class Kernel(SingletonConfigurable):\\n',\n",
       "  '\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '    # Kernel interface\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    # attribute to override with a GUI\\n',\n",
       "  '    eventloop = Any(None)\\n',\n",
       "  '    def _eventloop_changed(self, name, old, new):\\n',\n",
       "  '        \"\"\"schedule call to eventloop from IOLoop\"\"\"\\n',\n",
       "  '        loop = ioloop.IOLoop.instance()\\n',\n",
       "  '        loop.add_callback(self.enter_eventloop)\\n',\n",
       "  '\\n',\n",
       "  '    session = Instance(Session, allow_none=True)\\n',\n",
       "  \"    profile_dir = Instance('IPython.core.profiledir.ProfileDir', allow_none=True)\\n\",\n",
       "  '    shell_streams = List()\\n',\n",
       "  '    control_stream = Instance(ZMQStream, allow_none=True)\\n',\n",
       "  '    iopub_socket = Any()\\n',\n",
       "  '    iopub_thread = Any()\\n',\n",
       "  '    stdin_socket = Any()\\n',\n",
       "  '    log = Instance(logging.Logger, allow_none=True)\\n',\n",
       "  '\\n',\n",
       "  '    # identities:\\n',\n",
       "  '    int_id = Integer(-1)\\n',\n",
       "  '    ident = Unicode()\\n',\n",
       "  '\\n',\n",
       "  '    def _ident_default(self):\\n',\n",
       "  '        return unicode_type(uuid.uuid4())\\n',\n",
       "  '\\n',\n",
       "  '    # This should be overridden by wrapper kernels that implement any real\\n',\n",
       "  '    # language.\\n',\n",
       "  '    language_info = {}\\n',\n",
       "  '\\n',\n",
       "  '    # any links that should go in the help menu\\n',\n",
       "  '    help_links = List()\\n',\n",
       "  '\\n',\n",
       "  '    # Private interface\\n',\n",
       "  '\\n',\n",
       "  '    _darwin_app_nap = Bool(True, config=True,\\n',\n",
       "  '        help=\"\"\"Whether to use appnope for compatiblity with OS X App Nap.\\n',\n",
       "  '\\n',\n",
       "  '        Only affects OS X >= 10.9.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    # track associations with current request\\n',\n",
       "  '    _allow_stdin = Bool(False)\\n',\n",
       "  '    _parent_header = Dict()\\n',\n",
       "  \"    _parent_ident = Any(b'')\\n\",\n",
       "  '    # Time to sleep after flushing the stdout/err buffers in each execute\\n',\n",
       "  '    # cycle.  While this introduces a hard limit on the minimal latency of the\\n',\n",
       "  '    # execute cycle, it helps prevent output synchronization problems for\\n',\n",
       "  '    # clients.\\n',\n",
       "  '    # Units are in seconds.  The minimum zmq latency on local host is probably\\n',\n",
       "  '    # ~150 microseconds, set this to 500us for now.  We may need to increase it\\n',\n",
       "  \"    # a little if it's not enough after more interactive testing.\\n\",\n",
       "  '    _execute_sleep = Float(0.0005, config=True)\\n',\n",
       "  '\\n',\n",
       "  \"    # Frequency of the kernel's event loop.\\n\",\n",
       "  '    # Units are in seconds, kernel subclasses for GUI toolkits may need to\\n',\n",
       "  '    # adapt to milliseconds.\\n',\n",
       "  '    _poll_interval = Float(0.05, config=True)\\n',\n",
       "  '\\n',\n",
       "  '    # If the shutdown was requested over the network, we leave here the\\n',\n",
       "  '    # necessary reply message so it can be sent by our registered atexit\\n',\n",
       "  '    # handler.  This ensures that the reply is only sent to clients truly at\\n',\n",
       "  '    # the end of our shutdown process (which happens after the underlying\\n',\n",
       "  \"    # IPython shell's own shutdown).\\n\",\n",
       "  '    _shutdown_message = None\\n',\n",
       "  '\\n',\n",
       "  '    # This is a dict of port number that the kernel is listening on. It is set\\n',\n",
       "  '    # by record_ports and used by connect_request.\\n',\n",
       "  '    _recorded_ports = Dict()\\n',\n",
       "  '\\n',\n",
       "  '    # set of aborted msg_ids\\n',\n",
       "  '    aborted = Set()\\n',\n",
       "  '\\n',\n",
       "  '    # Track execution count here. For IPython, we override this to use the\\n',\n",
       "  '    # execution count we store in the shell.\\n',\n",
       "  '    execution_count = 0\\n',\n",
       "  '    \\n',\n",
       "  '    msg_types = [\\n',\n",
       "  \"        'execute_request', 'complete_request',\\n\",\n",
       "  \"        'inspect_request', 'history_request',\\n\",\n",
       "  \"        'comm_info_request', 'kernel_info_request',\\n\",\n",
       "  \"        'connect_request', 'shutdown_request',\\n\",\n",
       "  \"        'is_complete_request',\\n\",\n",
       "  '        # deprecated:\\n',\n",
       "  \"        'apply_request',\\n\",\n",
       "  '    ]\\n',\n",
       "  '    # add deprecated ipyparallel control messages\\n',\n",
       "  \"    control_msg_types = msg_types + ['clear_request', 'abort_request']\\n\",\n",
       "  '\\n',\n",
       "  '    def __init__(self, **kwargs):\\n',\n",
       "  '        super(Kernel, self).__init__(**kwargs)\\n',\n",
       "  '\\n',\n",
       "  '        # Build dict of handlers for message types\\n',\n",
       "  '        self.shell_handlers = {}\\n',\n",
       "  '        for msg_type in self.msg_types:\\n',\n",
       "  '            self.shell_handlers[msg_type] = getattr(self, msg_type)\\n',\n",
       "  '\\n',\n",
       "  '        self.control_handlers = {}\\n',\n",
       "  '        for msg_type in self.control_msg_types:\\n',\n",
       "  '            self.control_handlers[msg_type] = getattr(self, msg_type)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '    def dispatch_control(self, msg):\\n',\n",
       "  '        \"\"\"dispatch control requests\"\"\"\\n',\n",
       "  '        idents,msg = self.session.feed_identities(msg, copy=False)\\n',\n",
       "  '        try:\\n',\n",
       "  '            msg = self.session.deserialize(msg, content=True, copy=False)\\n',\n",
       "  '        except:\\n',\n",
       "  '            self.log.error(\"Invalid Control Message\", exc_info=True)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        self.log.debug(\"Control received: %s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '        # Set the parent message for side effects.\\n',\n",
       "  '        self.set_parent(idents, msg)\\n',\n",
       "  \"        self._publish_status(u'busy')\\n\",\n",
       "  '\\n',\n",
       "  \"        header = msg['header']\\n\",\n",
       "  \"        msg_type = header['msg_type']\\n\",\n",
       "  '\\n',\n",
       "  '        handler = self.control_handlers.get(msg_type, None)\\n',\n",
       "  '        if handler is None:\\n',\n",
       "  '            self.log.error(\"UNKNOWN CONTROL MESSAGE TYPE: %r\", msg_type)\\n',\n",
       "  '        else:\\n',\n",
       "  '            try:\\n',\n",
       "  '                handler(self.control_stream, idents, msg)\\n',\n",
       "  '            except Exception:\\n',\n",
       "  '                self.log.error(\"Exception in control handler:\", exc_info=True)\\n',\n",
       "  '\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  \"        self._publish_status(u'idle')\\n\",\n",
       "  '\\n',\n",
       "  '    def should_handle(self, stream, msg, idents):\\n',\n",
       "  '        \"\"\"Check whether a shell-channel message should be handled\\n',\n",
       "  '        \\n',\n",
       "  '        Allows subclasses to prevent handling of certain messages (e.g. aborted requests).\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        msg_id = msg['header']['msg_id']\\n\",\n",
       "  '        if msg_id in self.aborted:\\n',\n",
       "  \"            msg_type = msg['header']['msg_type']\\n\",\n",
       "  '            # is it safe to assume a msg_id will not be resubmitted?\\n',\n",
       "  '            self.aborted.remove(msg_id)\\n',\n",
       "  \"            reply_type = msg_type.split('_')[0] + '_reply'\\n\",\n",
       "  \"            status = {'status' : 'aborted'}\\n\",\n",
       "  \"            md = {'engine' : self.ident}\\n\",\n",
       "  '            md.update(status)\\n',\n",
       "  '            self.session.send(stream, reply_type, metadata=md,\\n',\n",
       "  '                        content=status, parent=msg, ident=idents)\\n',\n",
       "  '            return False\\n',\n",
       "  '        return True\\n',\n",
       "  '\\n',\n",
       "  '    def dispatch_shell(self, stream, msg):\\n',\n",
       "  '        \"\"\"dispatch shell requests\"\"\"\\n',\n",
       "  '        # flush control requests first\\n',\n",
       "  '        if self.control_stream:\\n',\n",
       "  '            self.control_stream.flush()\\n',\n",
       "  '\\n',\n",
       "  '        idents,msg = self.session.feed_identities(msg, copy=False)\\n',\n",
       "  '        try:\\n',\n",
       "  '            msg = self.session.deserialize(msg, content=True, copy=False)\\n',\n",
       "  '        except:\\n',\n",
       "  '            self.log.error(\"Invalid Message\", exc_info=True)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        # Set the parent message for side effects.\\n',\n",
       "  '        self.set_parent(idents, msg)\\n',\n",
       "  \"        self._publish_status(u'busy')\\n\",\n",
       "  '\\n',\n",
       "  \"        header = msg['header']\\n\",\n",
       "  \"        msg_id = header['msg_id']\\n\",\n",
       "  \"        msg_type = msg['header']['msg_type']\\n\",\n",
       "  '\\n',\n",
       "  \"        # Print some info about this message and leave a '--->' marker, so it's\\n\",\n",
       "  '        # easier to trace visually the message chain when debugging.  Each\\n',\n",
       "  '        # handler prints its message at the end.\\n',\n",
       "  \"        self.log.debug('\\\\n*** MESSAGE TYPE:%s***', msg_type)\\n\",\n",
       "  \"        self.log.debug('   Content: %s\\\\n   --->\\\\n   ', msg['content'])\\n\",\n",
       "  '\\n',\n",
       "  '        if not self.should_handle(stream, msg, idents):\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        handler = self.shell_handlers.get(msg_type, None)\\n',\n",
       "  '        if handler is None:\\n',\n",
       "  '            self.log.error(\"UNKNOWN MESSAGE TYPE: %r\", msg_type)\\n',\n",
       "  '        else:\\n',\n",
       "  '            self.log.debug(\"%s: %s\", msg_type, msg)\\n',\n",
       "  '            self.pre_handler_hook()\\n',\n",
       "  '            try:\\n',\n",
       "  '                handler(stream, idents, msg)\\n',\n",
       "  '            except Exception:\\n',\n",
       "  '                self.log.error(\"Exception in message handler:\", exc_info=True)\\n',\n",
       "  '            finally:\\n',\n",
       "  '                self.post_handler_hook()\\n',\n",
       "  '\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  \"        self._publish_status(u'idle')\\n\",\n",
       "  '\\n',\n",
       "  '    def pre_handler_hook(self):\\n',\n",
       "  '        \"\"\"Hook to execute before calling message handler\"\"\"\\n',\n",
       "  '        # ensure default_int_handler during handler call\\n',\n",
       "  '        self.saved_sigint_handler = signal(SIGINT, default_int_handler)\\n',\n",
       "  '\\n',\n",
       "  '    def post_handler_hook(self):\\n',\n",
       "  '        \"\"\"Hook to execute after calling message handler\"\"\"\\n',\n",
       "  '        signal(SIGINT, self.saved_sigint_handler)\\n',\n",
       "  '\\n',\n",
       "  '    def enter_eventloop(self):\\n',\n",
       "  '        \"\"\"enter eventloop\"\"\"\\n',\n",
       "  '        self.log.info(\"entering eventloop %s\", self.eventloop)\\n',\n",
       "  '        for stream in self.shell_streams:\\n',\n",
       "  '            # flush any pending replies,\\n',\n",
       "  '            # which may be skipped by entering the eventloop\\n',\n",
       "  '            stream.flush(zmq.POLLOUT)\\n',\n",
       "  '        # restore default_int_handler\\n',\n",
       "  '        signal(SIGINT, default_int_handler)\\n',\n",
       "  '        while self.eventloop is not None:\\n',\n",
       "  '            try:\\n',\n",
       "  '                self.eventloop(self)\\n',\n",
       "  '            except KeyboardInterrupt:\\n',\n",
       "  \"                # Ctrl-C shouldn't crash the kernel\\n\",\n",
       "  '                self.log.error(\"KeyboardInterrupt caught in kernel\")\\n',\n",
       "  '                continue\\n',\n",
       "  '            else:\\n',\n",
       "  '                # eventloop exited cleanly, this means we should stop (right?)\\n',\n",
       "  '                self.eventloop = None\\n',\n",
       "  '                break\\n',\n",
       "  '        self.log.info(\"exiting eventloop\")\\n',\n",
       "  '\\n',\n",
       "  '    def start(self):\\n',\n",
       "  '        \"\"\"register dispatchers for streams\"\"\"\\n',\n",
       "  '        if self.control_stream:\\n',\n",
       "  '            self.control_stream.on_recv(self.dispatch_control, copy=False)\\n',\n",
       "  '\\n',\n",
       "  '        def make_dispatcher(stream):\\n',\n",
       "  '            def dispatcher(msg):\\n',\n",
       "  '                return self.dispatch_shell(stream, msg)\\n',\n",
       "  '            return dispatcher\\n',\n",
       "  '\\n',\n",
       "  '        for s in self.shell_streams:\\n',\n",
       "  '            s.on_recv(make_dispatcher(s), copy=False)\\n',\n",
       "  '\\n',\n",
       "  '        # publish idle status\\n',\n",
       "  \"        self._publish_status('starting')\\n\",\n",
       "  '\\n',\n",
       "  '    def do_one_iteration(self):\\n',\n",
       "  '        \"\"\"step eventloop just once\"\"\"\\n',\n",
       "  '        if self.control_stream:\\n',\n",
       "  '            self.control_stream.flush()\\n',\n",
       "  '        for stream in self.shell_streams:\\n',\n",
       "  '            # handle at most one request per iteration\\n',\n",
       "  '            stream.flush(zmq.POLLIN, 1)\\n',\n",
       "  '            stream.flush(zmq.POLLOUT)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '    def record_ports(self, ports):\\n',\n",
       "  '        \"\"\"Record the ports that this kernel is using.\\n',\n",
       "  '\\n',\n",
       "  '        The creator of the Kernel instance must call this methods if they\\n',\n",
       "  '        want the :meth:`connect_request` method to return the port numbers.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        self._recorded_ports = ports\\n',\n",
       "  '\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '    # Kernel request handlers\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def _publish_execute_input(self, code, parent, execution_count):\\n',\n",
       "  '        \"\"\"Publish the code request on the iopub stream.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  \"        self.session.send(self.iopub_socket, u'execute_input',\\n\",\n",
       "  \"                            {u'code':code, u'execution_count': execution_count},\\n\",\n",
       "  \"                            parent=parent, ident=self._topic('execute_input')\\n\",\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '    def _publish_status(self, status, parent=None):\\n',\n",
       "  '        \"\"\"send status (busy/idle) on IOPub\"\"\"\\n',\n",
       "  '        self.session.send(self.iopub_socket,\\n',\n",
       "  \"                          u'status',\\n\",\n",
       "  \"                          {u'execution_state': status},\\n\",\n",
       "  '                          parent=parent or self._parent_header,\\n',\n",
       "  \"                          ident=self._topic('status'),\\n\",\n",
       "  '                          )\\n',\n",
       "  '\\n',\n",
       "  '    def set_parent(self, ident, parent):\\n',\n",
       "  '        \"\"\"Set the current parent_header\\n',\n",
       "  '\\n',\n",
       "  '        Side effects (IOPub messages) and replies are associated with\\n',\n",
       "  '        the request that caused them via the parent_header.\\n',\n",
       "  '\\n',\n",
       "  '        The parent identity is used to route input_request messages\\n',\n",
       "  '        on the stdin channel.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        self._parent_ident = ident\\n',\n",
       "  '        self._parent_header = parent\\n',\n",
       "  '\\n',\n",
       "  '    def send_response(self, stream, msg_or_type, content=None, ident=None,\\n',\n",
       "  '             buffers=None, track=False, header=None, metadata=None):\\n',\n",
       "  '        \"\"\"Send a response to the message we\\'re currently processing.\\n',\n",
       "  '\\n',\n",
       "  '        This accepts all the parameters of :meth:`jupyter_client.session.Session.send`\\n',\n",
       "  '        except ``parent``.\\n',\n",
       "  '\\n',\n",
       "  '        This relies on :meth:`set_parent` having been called for the current\\n',\n",
       "  '        message.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        return self.session.send(stream, msg_or_type, content, self._parent_header,\\n',\n",
       "  '                                 ident, buffers, track, header, metadata)\\n',\n",
       "  '    \\n',\n",
       "  '    def init_metadata(self, parent):\\n',\n",
       "  '        \"\"\"Initialize metadata.\\n',\n",
       "  '        \\n',\n",
       "  '        Run at the beginning of execution requests.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        return {\\n',\n",
       "  \"            'started': datetime.now(),\\n\",\n",
       "  '        }\\n',\n",
       "  '    \\n',\n",
       "  '    def finish_metadata(self, parent, metadata, reply_content):\\n',\n",
       "  '        \"\"\"Finish populating metadata.\\n',\n",
       "  '        \\n',\n",
       "  '        Run after completing an execution request.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        return metadata\\n',\n",
       "  '\\n',\n",
       "  '    def execute_request(self, stream, ident, parent):\\n',\n",
       "  '        \"\"\"handle an execute_request\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  \"            content = parent[u'content']\\n\",\n",
       "  \"            code = py3compat.cast_unicode_py2(content[u'code'])\\n\",\n",
       "  \"            silent = content[u'silent']\\n\",\n",
       "  \"            store_history = content.get(u'store_history', not silent)\\n\",\n",
       "  \"            user_expressions = content.get('user_expressions', {})\\n\",\n",
       "  \"            allow_stdin = content.get('allow_stdin', False)\\n\",\n",
       "  '        except:\\n',\n",
       "  '            self.log.error(\"Got bad msg: \")\\n',\n",
       "  '            self.log.error(\"%s\", parent)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  \"        stop_on_error = content.get('stop_on_error', True)\\n\",\n",
       "  '\\n',\n",
       "  '        metadata = self.init_metadata(parent)\\n',\n",
       "  '\\n',\n",
       "  '        # Re-broadcast our input for the benefit of listening clients, and\\n',\n",
       "  '        # start computing output\\n',\n",
       "  '        if not silent:\\n',\n",
       "  '            self.execution_count += 1\\n',\n",
       "  '            self._publish_execute_input(code, parent, self.execution_count)\\n',\n",
       "  '\\n',\n",
       "  '        reply_content = self.do_execute(code, silent, store_history,\\n',\n",
       "  '                                        user_expressions, allow_stdin)\\n',\n",
       "  '\\n',\n",
       "  '        # Flush output before sending the reply.\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  \"        # FIXME: on rare occasions, the flush doesn't seem to make it to the\\n\",\n",
       "  '        # clients... This seems to mitigate the problem, but we definitely need\\n',\n",
       "  \"        # to better understand what's going on.\\n\",\n",
       "  '        if self._execute_sleep:\\n',\n",
       "  '            time.sleep(self._execute_sleep)\\n',\n",
       "  '\\n',\n",
       "  '        # Send the reply.\\n',\n",
       "  '        reply_content = json_clean(reply_content)\\n',\n",
       "  '        metadata = self.finish_metadata(parent, metadata, reply_content)\\n',\n",
       "  '\\n',\n",
       "  \"        reply_msg = self.session.send(stream, u'execute_reply',\\n\",\n",
       "  '                                      reply_content, parent, metadata=metadata,\\n',\n",
       "  '                                      ident=ident)\\n',\n",
       "  '\\n',\n",
       "  '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "  '\\n',\n",
       "  \"        if not silent and reply_msg['content']['status'] == u'error' and stop_on_error:\\n\",\n",
       "  '            self._abort_queues()\\n',\n",
       "  '\\n',\n",
       "  '    def do_execute(self, code, silent, store_history=True,\\n',\n",
       "  '                   user_expressions=None, allow_stdin=False):\\n',\n",
       "  '        \"\"\"Execute user code. Must be overridden by subclasses.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    def complete_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = parent['content']\\n\",\n",
       "  \"        code = content['code']\\n\",\n",
       "  \"        cursor_pos = content['cursor_pos']\\n\",\n",
       "  '\\n',\n",
       "  '        matches = self.do_complete(code, cursor_pos)\\n',\n",
       "  '        matches = json_clean(matches)\\n',\n",
       "  \"        completion_msg = self.session.send(stream, 'complete_reply',\\n\",\n",
       "  '                                           matches, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", completion_msg)\\n',\n",
       "  '\\n',\n",
       "  '    def do_complete(self, code, cursor_pos):\\n',\n",
       "  '        \"\"\"Override in subclasses to find completions.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return {'matches' : [],\\n\",\n",
       "  \"                'cursor_end' : cursor_pos,\\n\",\n",
       "  \"                'cursor_start' : cursor_pos,\\n\",\n",
       "  \"                'metadata' : {},\\n\",\n",
       "  \"                'status' : 'ok'}\\n\",\n",
       "  '\\n',\n",
       "  '    def inspect_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = parent['content']\\n\",\n",
       "  '\\n',\n",
       "  \"        reply_content = self.do_inspect(content['code'], content['cursor_pos'],\\n\",\n",
       "  \"                                        content.get('detail_level', 0))\\n\",\n",
       "  '        # Before we send this object over, we scrub it for JSON usage\\n',\n",
       "  '        reply_content = json_clean(reply_content)\\n',\n",
       "  \"        msg = self.session.send(stream, 'inspect_reply',\\n\",\n",
       "  '                                reply_content, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '    def do_inspect(self, code, cursor_pos, detail_level=0):\\n',\n",
       "  '        \"\"\"Override in subclasses to allow introspection.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return {'status': 'ok', 'data': {}, 'metadata': {}, 'found': False}\\n\",\n",
       "  '\\n',\n",
       "  '    def history_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = parent['content']\\n\",\n",
       "  '\\n',\n",
       "  '        reply_content = self.do_history(**content)\\n',\n",
       "  '\\n',\n",
       "  '        reply_content = json_clean(reply_content)\\n',\n",
       "  \"        msg = self.session.send(stream, 'history_reply',\\n\",\n",
       "  '                                reply_content, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '    def do_history(self, hist_access_type, output, raw, session=None, start=None,\\n',\n",
       "  '                   stop=None, n=None, pattern=None, unique=False):\\n',\n",
       "  '        \"\"\"Override in subclasses to access history.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return {'history': []}\\n\",\n",
       "  '\\n',\n",
       "  '    def connect_request(self, stream, ident, parent):\\n',\n",
       "  '        if self._recorded_ports is not None:\\n',\n",
       "  '            content = self._recorded_ports.copy()\\n',\n",
       "  '        else:\\n',\n",
       "  '            content = {}\\n',\n",
       "  \"        msg = self.session.send(stream, 'connect_reply',\\n\",\n",
       "  '                                content, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '    @property\\n',\n",
       "  '    def kernel_info(self):\\n',\n",
       "  '        return {\\n',\n",
       "  \"            'protocol_version': kernel_protocol_version,\\n\",\n",
       "  \"            'implementation': self.implementation,\\n\",\n",
       "  \"            'implementation_version': self.implementation_version,\\n\",\n",
       "  \"            'language_info': self.language_info,\\n\",\n",
       "  \"            'banner': self.banner,\\n\",\n",
       "  \"            'help_links': self.help_links,\\n\",\n",
       "  '        }\\n',\n",
       "  '\\n',\n",
       "  '    def kernel_info_request(self, stream, ident, parent):\\n',\n",
       "  \"        msg = self.session.send(stream, 'kernel_info_reply',\\n\",\n",
       "  '                                self.kernel_info, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '    def comm_info_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = parent['content']\\n\",\n",
       "  \"        target_name = content.get('target_name', None)\\n\",\n",
       "  '\\n',\n",
       "  '        # Should this be moved to ipkernel?\\n',\n",
       "  \"        if hasattr(self, 'comm_manager'):\\n\",\n",
       "  '            comms = {\\n',\n",
       "  '                k: dict(target_name=v.target_name)\\n',\n",
       "  '                for (k, v) in self.comm_manager.comms.items()\\n',\n",
       "  '                if v.target_name == target_name or target_name is None\\n',\n",
       "  '            }\\n',\n",
       "  '        else:\\n',\n",
       "  '            comms = {}\\n',\n",
       "  '        reply_content = dict(comms=comms)\\n',\n",
       "  \"        msg = self.session.send(stream, 'comm_info_reply',\\n\",\n",
       "  '                                reply_content, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", msg)\\n',\n",
       "  '\\n',\n",
       "  '    def shutdown_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = self.do_shutdown(parent['content']['restart'])\\n\",\n",
       "  \"        self.session.send(stream, u'shutdown_reply', content, parent, ident=ident)\\n\",\n",
       "  '        # same content, but different msg_id for broadcasting on IOPub\\n',\n",
       "  \"        self._shutdown_message = self.session.msg(u'shutdown_reply',\\n\",\n",
       "  '                                                  content, parent\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '        self._at_shutdown()\\n',\n",
       "  '        # call sys.exit after a short delay\\n',\n",
       "  '        loop = ioloop.IOLoop.instance()\\n',\n",
       "  '        loop.add_timeout(time.time()+0.1, loop.stop)\\n',\n",
       "  '\\n',\n",
       "  '    def do_shutdown(self, restart):\\n',\n",
       "  '        \"\"\"Override in subclasses to do things when the frontend shuts down the\\n',\n",
       "  '        kernel.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return {'status': 'ok', 'restart': restart}\\n\",\n",
       "  '\\n',\n",
       "  '    def is_complete_request(self, stream, ident, parent):\\n',\n",
       "  \"        content = parent['content']\\n\",\n",
       "  \"        code = content['code']\\n\",\n",
       "  '\\n',\n",
       "  '        reply_content = self.do_is_complete(code)\\n',\n",
       "  '        reply_content = json_clean(reply_content)\\n',\n",
       "  \"        reply_msg = self.session.send(stream, 'is_complete_reply',\\n\",\n",
       "  '                                           reply_content, parent, ident)\\n',\n",
       "  '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "  '\\n',\n",
       "  '    def do_is_complete(self, code):\\n',\n",
       "  '        \"\"\"Override in subclasses to find completions.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return {'status' : 'unknown',\\n\",\n",
       "  '                }\\n',\n",
       "  '\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '    # Engine methods (DEPRECATED)\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def apply_request(self, stream, ident, parent):\\n',\n",
       "  '        self.log.warn(\"\"\"apply_request is deprecated in kernel_base, moving to ipyparallel.\"\"\")\\n',\n",
       "  '        try:\\n',\n",
       "  \"            content = parent[u'content']\\n\",\n",
       "  \"            bufs = parent[u'buffers']\\n\",\n",
       "  \"            msg_id = parent['header']['msg_id']\\n\",\n",
       "  '        except:\\n',\n",
       "  '            self.log.error(\"Got bad msg: %s\", parent, exc_info=True)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        md = self.init_metadata(parent)\\n',\n",
       "  '\\n',\n",
       "  '        reply_content, result_buf = self.do_apply(content, bufs, msg_id, md)\\n',\n",
       "  '        \\n',\n",
       "  '        # flush i/o\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  '\\n',\n",
       "  '        md = self.finish_metadata(parent, md, reply_content)\\n',\n",
       "  '\\n',\n",
       "  \"        self.session.send(stream, u'apply_reply', reply_content,\\n\",\n",
       "  '                    parent=parent, ident=ident,buffers=result_buf, metadata=md)\\n',\n",
       "  '\\n',\n",
       "  '    def do_apply(self, content, bufs, msg_id, reply_metadata):\\n',\n",
       "  '        \"\"\"DEPRECATED\"\"\"\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '    # Control messages (DEPRECATED)\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def abort_request(self, stream, ident, parent):\\n',\n",
       "  '        \"\"\"abort a specific msg by id\"\"\"\\n',\n",
       "  '        self.log.warn(\"abort_request is deprecated in kernel_base. It os only part of IPython parallel\")\\n',\n",
       "  \"        msg_ids = parent['content'].get('msg_ids', None)\\n\",\n",
       "  '        if isinstance(msg_ids, string_types):\\n',\n",
       "  '            msg_ids = [msg_ids]\\n',\n",
       "  '        if not msg_ids:\\n',\n",
       "  '            self._abort_queues()\\n',\n",
       "  '        for mid in msg_ids:\\n',\n",
       "  '            self.aborted.add(str(mid))\\n',\n",
       "  '\\n',\n",
       "  \"        content = dict(status='ok')\\n\",\n",
       "  \"        reply_msg = self.session.send(stream, 'abort_reply', content=content,\\n\",\n",
       "  '                parent=parent, ident=ident)\\n',\n",
       "  '        self.log.debug(\"%s\", reply_msg)\\n',\n",
       "  '\\n',\n",
       "  '    def clear_request(self, stream, idents, parent):\\n',\n",
       "  '        \"\"\"Clear our namespace.\"\"\"\\n',\n",
       "  '        self.log.warn(\"clear_request is deprecated in kernel_base. It os only part of IPython parallel\")\\n',\n",
       "  '        content = self.do_clear()\\n',\n",
       "  \"        self.session.send(stream, 'clear_reply', ident=idents, parent=parent,\\n\",\n",
       "  '                content = content)\\n',\n",
       "  '\\n',\n",
       "  '    def do_clear(self):\\n',\n",
       "  '        \"\"\"DEPRECATED\"\"\"\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '    # Protected interface\\n',\n",
       "  '    #---------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def _topic(self, topic):\\n',\n",
       "  '        \"\"\"prefixed topic for IOPub messages\"\"\"\\n',\n",
       "  '        base = \"kernel.%s\" % self.ident\\n',\n",
       "  '\\n',\n",
       "  '        return py3compat.cast_bytes(\"%s.%s\" % (base, topic))\\n',\n",
       "  '\\n',\n",
       "  '    def _abort_queues(self):\\n',\n",
       "  '        for stream in self.shell_streams:\\n',\n",
       "  '            if stream:\\n',\n",
       "  '                self._abort_queue(stream)\\n',\n",
       "  '\\n',\n",
       "  '    def _abort_queue(self, stream):\\n',\n",
       "  '        poller = zmq.Poller()\\n',\n",
       "  '        poller.register(stream.socket, zmq.POLLIN)\\n',\n",
       "  '        while True:\\n',\n",
       "  '            idents,msg = self.session.recv(stream, zmq.NOBLOCK, content=True)\\n',\n",
       "  '            if msg is None:\\n',\n",
       "  '                return\\n',\n",
       "  '\\n',\n",
       "  '            self.log.info(\"Aborting:\")\\n',\n",
       "  '            self.log.info(\"%s\", msg)\\n',\n",
       "  \"            msg_type = msg['header']['msg_type']\\n\",\n",
       "  \"            reply_type = msg_type.split('_')[0] + '_reply'\\n\",\n",
       "  '\\n',\n",
       "  \"            status = {'status' : 'aborted'}\\n\",\n",
       "  \"            md = {'engine' : self.ident}\\n\",\n",
       "  '            md.update(status)\\n',\n",
       "  '            reply_msg = self.session.send(stream, reply_type, metadata=md,\\n',\n",
       "  '                        content=status, parent=msg, ident=idents)\\n',\n",
       "  '            self.log.debug(\"%s\", reply_msg)\\n',\n",
       "  '            # We need to wait a bit for requests to come in. This can probably\\n',\n",
       "  '            # be set shorter for true asynchronous clients.\\n',\n",
       "  '            poller.poll(50)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '    def _no_raw_input(self):\\n',\n",
       "  '        \"\"\"Raise StdinNotImplentedError if active frontend doesn\\'t support\\n',\n",
       "  '        stdin.\"\"\"\\n',\n",
       "  '        raise StdinNotImplementedError(\"raw_input was called, but this \"\\n',\n",
       "  '                                       \"frontend does not support stdin.\")\\n',\n",
       "  '\\n',\n",
       "  \"    def getpass(self, prompt=''):\\n\",\n",
       "  '        \"\"\"Forward getpass to frontends\\n',\n",
       "  '\\n',\n",
       "  '        Raises\\n',\n",
       "  '        ------\\n',\n",
       "  \"        StdinNotImplentedError if active frontend doesn't support stdin.\\n\",\n",
       "  '        \"\"\"\\n',\n",
       "  '        if not self._allow_stdin:\\n',\n",
       "  '            raise StdinNotImplementedError(\\n',\n",
       "  '                \"getpass was called, but this frontend does not support input requests.\"\\n',\n",
       "  '            )\\n',\n",
       "  '        return self._input_request(prompt,\\n',\n",
       "  '            self._parent_ident,\\n',\n",
       "  '            self._parent_header,\\n',\n",
       "  '            password=True,\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  \"    def raw_input(self, prompt=''):\\n\",\n",
       "  '        \"\"\"Forward raw_input to frontends\\n',\n",
       "  '\\n',\n",
       "  '        Raises\\n',\n",
       "  '        ------\\n',\n",
       "  \"        StdinNotImplentedError if active frontend doesn't support stdin.\\n\",\n",
       "  '        \"\"\"\\n',\n",
       "  '        if not self._allow_stdin:\\n',\n",
       "  '            raise StdinNotImplementedError(\\n',\n",
       "  '                \"raw_input was called, but this frontend does not support input requests.\"\\n',\n",
       "  '            )\\n',\n",
       "  '        return self._input_request(prompt,\\n',\n",
       "  '            self._parent_ident,\\n',\n",
       "  '            self._parent_header,\\n',\n",
       "  '            password=False,\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '    def _input_request(self, prompt, ident, parent, password=False):\\n',\n",
       "  '        # Flush output before making the request.\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        # flush the stdin socket, to purge stale replies\\n',\n",
       "  '        while True:\\n',\n",
       "  '            try:\\n',\n",
       "  '                self.stdin_socket.recv_multipart(zmq.NOBLOCK)\\n',\n",
       "  '            except zmq.ZMQError as e:\\n',\n",
       "  '                if e.errno == zmq.EAGAIN:\\n',\n",
       "  '                    break\\n',\n",
       "  '                else:\\n',\n",
       "  '                    raise\\n',\n",
       "  '\\n',\n",
       "  '        # Send the input request.\\n',\n",
       "  '        content = json_clean(dict(prompt=prompt, password=password))\\n',\n",
       "  \"        self.session.send(self.stdin_socket, u'input_request', content, parent,\\n\",\n",
       "  '                          ident=ident)\\n',\n",
       "  '\\n',\n",
       "  '        # Await a response.\\n',\n",
       "  '        while True:\\n',\n",
       "  '            try:\\n',\n",
       "  '                ident, reply = self.session.recv(self.stdin_socket, 0)\\n',\n",
       "  '            except Exception:\\n',\n",
       "  '                self.log.warn(\"Invalid Message:\", exc_info=True)\\n',\n",
       "  '            except KeyboardInterrupt:\\n',\n",
       "  '                # re-raise KeyboardInterrupt, to truncate traceback\\n',\n",
       "  '                raise KeyboardInterrupt\\n',\n",
       "  '            else:\\n',\n",
       "  '                break\\n',\n",
       "  '        try:\\n',\n",
       "  \"            value = py3compat.unicode_to_str(reply['content']['value'])\\n\",\n",
       "  '        except:\\n',\n",
       "  '            self.log.error(\"Bad input_reply: %s\", parent)\\n',\n",
       "  \"            value = ''\\n\",\n",
       "  \"        if value == '\\\\x04':\\n\",\n",
       "  '            # EOF\\n',\n",
       "  '            raise EOFError\\n',\n",
       "  '        return value\\n',\n",
       "  '\\n',\n",
       "  '    def _at_shutdown(self):\\n',\n",
       "  '        \"\"\"Actions taken at shutdown by the kernel, called by python\\'s atexit.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        # io.rprint(\"Kernel at_shutdown\") # dbg\\n',\n",
       "  '        if self._shutdown_message is not None:\\n',\n",
       "  \"            self.session.send(self.iopub_socket, self._shutdown_message, ident=self._topic('shutdown'))\\n\",\n",
       "  '            self.log.debug(\"%s\", self._shutdown_message)\\n',\n",
       "  '        [ s.flush(zmq.POLLOUT) for s in self.shell_streams ]\\n'],\n",
       " ['\"\"\"The IPython kernel implementation\"\"\"\\n',\n",
       "  '\\n',\n",
       "  'import getpass\\n',\n",
       "  'import sys\\n',\n",
       "  'import traceback\\n',\n",
       "  '\\n',\n",
       "  'from IPython.core import release\\n',\n",
       "  'from ipython_genutils.py3compat import builtin_mod, PY3\\n',\n",
       "  'from IPython.utils.tokenutil import token_at_cursor, line_at_cursor\\n',\n",
       "  'from traitlets import Instance, Type, Any, List\\n',\n",
       "  '\\n',\n",
       "  'from .comm import CommManager\\n',\n",
       "  'from .kernelbase import Kernel as KernelBase\\n',\n",
       "  'from .zmqshell import ZMQInteractiveShell\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class IPythonKernel(KernelBase):\\n',\n",
       "  \"    shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',\\n\",\n",
       "  '                     allow_none=True)\\n',\n",
       "  '    shell_class = Type(ZMQInteractiveShell)\\n',\n",
       "  '\\n',\n",
       "  '    user_module = Any()\\n',\n",
       "  '    def _user_module_changed(self, name, old, new):\\n',\n",
       "  '        if self.shell is not None:\\n',\n",
       "  '            self.shell.user_module = new\\n',\n",
       "  '\\n',\n",
       "  '    user_ns = Instance(dict, args=None, allow_none=True)\\n',\n",
       "  '    def _user_ns_changed(self, name, old, new):\\n',\n",
       "  '        if self.shell is not None:\\n',\n",
       "  '            self.shell.user_ns = new\\n',\n",
       "  '            self.shell.init_user_ns()\\n',\n",
       "  '\\n',\n",
       "  \"    # A reference to the Python builtin 'raw_input' function.\\n\",\n",
       "  '    # (i.e., __builtin__.raw_input for Python 2.7, builtins.input for Python 3)\\n',\n",
       "  '    _sys_raw_input = Any()\\n',\n",
       "  '    _sys_eval_input = Any()\\n',\n",
       "  '\\n',\n",
       "  '    def __init__(self, **kwargs):\\n',\n",
       "  '        super(IPythonKernel, self).__init__(**kwargs)\\n',\n",
       "  '\\n',\n",
       "  '        # Initialize the InteractiveShell subclass\\n',\n",
       "  '        self.shell = self.shell_class.instance(parent=self,\\n',\n",
       "  '            profile_dir = self.profile_dir,\\n',\n",
       "  '            user_module = self.user_module,\\n',\n",
       "  '            user_ns     = self.user_ns,\\n',\n",
       "  '            kernel      = self,\\n',\n",
       "  '        )\\n',\n",
       "  '        self.shell.displayhook.session = self.session\\n',\n",
       "  '        self.shell.displayhook.pub_socket = self.iopub_socket\\n',\n",
       "  \"        self.shell.displayhook.topic = self._topic('execute_result')\\n\",\n",
       "  '        self.shell.display_pub.session = self.session\\n',\n",
       "  '        self.shell.display_pub.pub_socket = self.iopub_socket\\n',\n",
       "  '\\n',\n",
       "  '        # TMP - hack while developing\\n',\n",
       "  '        self.shell._reply_content = None\\n',\n",
       "  '\\n',\n",
       "  '        self.comm_manager = CommManager(shell=self.shell, parent=self,\\n',\n",
       "  '                                        kernel=self)\\n',\n",
       "  '\\n',\n",
       "  '        self.shell.configurables.append(self.comm_manager)\\n',\n",
       "  \"        comm_msg_types = [ 'comm_open', 'comm_msg', 'comm_close' ]\\n\",\n",
       "  '        for msg_type in comm_msg_types:\\n',\n",
       "  '            self.shell_handlers[msg_type] = getattr(self.comm_manager, msg_type)\\n',\n",
       "  '\\n',\n",
       "  '    help_links = List([\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"Python\",\\n',\n",
       "  '            \\'url\\': \"http://docs.python.org/%i.%i\" % sys.version_info[:2],\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"IPython\",\\n',\n",
       "  '            \\'url\\': \"http://ipython.org/documentation.html\",\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"NumPy\",\\n',\n",
       "  '            \\'url\\': \"http://docs.scipy.org/doc/numpy/reference/\",\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"SciPy\",\\n',\n",
       "  '            \\'url\\': \"http://docs.scipy.org/doc/scipy/reference/\",\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"Matplotlib\",\\n',\n",
       "  '            \\'url\\': \"http://matplotlib.org/contents.html\",\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"SymPy\",\\n',\n",
       "  '            \\'url\\': \"http://docs.sympy.org/latest/index.html\",\\n',\n",
       "  '        },\\n',\n",
       "  '        {\\n',\n",
       "  '            \\'text\\': \"pandas\",\\n',\n",
       "  '            \\'url\\': \"http://pandas.pydata.org/pandas-docs/stable/\",\\n',\n",
       "  '        },\\n',\n",
       "  '    ])\\n',\n",
       "  '\\n',\n",
       "  '    # Kernel info fields\\n',\n",
       "  \"    implementation = 'ipython'\\n\",\n",
       "  '    implementation_version = release.version\\n',\n",
       "  '    language_info = {\\n',\n",
       "  \"                     'name': 'python',\\n\",\n",
       "  \"                     'version': sys.version.split()[0],\\n\",\n",
       "  \"                     'mimetype': 'text/x-python',\\n\",\n",
       "  \"                     'codemirror_mode': {'name': 'ipython',\\n\",\n",
       "  \"                                         'version': sys.version_info[0]},\\n\",\n",
       "  \"                     'pygments_lexer': 'ipython%d' % (3 if PY3 else 2),\\n\",\n",
       "  \"                     'nbconvert_exporter': 'python',\\n\",\n",
       "  \"                     'file_extension': '.py'\\n\",\n",
       "  '                    }\\n',\n",
       "  '    @property\\n',\n",
       "  '    def banner(self):\\n',\n",
       "  '        return self.shell.banner\\n',\n",
       "  '\\n',\n",
       "  '    def start(self):\\n',\n",
       "  '        self.shell.exit_now = False\\n',\n",
       "  '        super(IPythonKernel, self).start()\\n',\n",
       "  '\\n',\n",
       "  '    def set_parent(self, ident, parent):\\n',\n",
       "  '        \"\"\"Overridden from parent to tell the display hook and output streams\\n',\n",
       "  '        about the parent message.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        super(IPythonKernel, self).set_parent(ident, parent)\\n',\n",
       "  '        self.shell.set_parent(parent)\\n',\n",
       "  '\\n',\n",
       "  '    def init_metadata(self, parent):\\n',\n",
       "  '        \"\"\"Initialize metadata.\\n',\n",
       "  '        \\n',\n",
       "  '        Run at the beginning of each execution request.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        md = super(IPythonKernel, self).init_metadata(parent)\\n',\n",
       "  '        # FIXME: remove deprecated ipyparallel-specific code\\n',\n",
       "  '        # This is required for ipyparallel < 5.0\\n',\n",
       "  '        md.update({\\n',\n",
       "  \"            'dependencies_met' : True,\\n\",\n",
       "  \"            'engine' : self.ident,\\n\",\n",
       "  '        })\\n',\n",
       "  '        return md\\n',\n",
       "  '    \\n',\n",
       "  '    def finish_metadata(self, parent, metadata, reply_content):\\n',\n",
       "  '        \"\"\"Finish populating metadata.\\n',\n",
       "  '        \\n',\n",
       "  '        Run after completing an execution request.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        # FIXME: remove deprecated ipyparallel-specific code\\n',\n",
       "  '        # This is required by ipyparallel < 5.0\\n',\n",
       "  \"        metadata['status'] = reply_content['status']\\n\",\n",
       "  \"        if reply_content['status'] == 'error' and reply_content['ename'] == 'UnmetDependency':\\n\",\n",
       "  \"                metadata['dependencies_met'] = False\\n\",\n",
       "  '\\n',\n",
       "  '        return metadata\\n',\n",
       "  '\\n',\n",
       "  '    def _forward_input(self, allow_stdin=False):\\n',\n",
       "  '        \"\"\"Forward raw_input and getpass to the current frontend.\\n',\n",
       "  '\\n',\n",
       "  '        via input_request\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        self._allow_stdin = allow_stdin\\n',\n",
       "  '\\n',\n",
       "  '        if PY3:\\n',\n",
       "  '            self._sys_raw_input = builtin_mod.input\\n',\n",
       "  '            builtin_mod.input = self.raw_input\\n',\n",
       "  '        else:\\n',\n",
       "  '            self._sys_raw_input = builtin_mod.raw_input\\n',\n",
       "  '            self._sys_eval_input = builtin_mod.input\\n',\n",
       "  '            builtin_mod.raw_input = self.raw_input\\n',\n",
       "  \"            builtin_mod.input = lambda prompt='': eval(self.raw_input(prompt))\\n\",\n",
       "  '        self._save_getpass = getpass.getpass\\n',\n",
       "  '        getpass.getpass = self.getpass\\n',\n",
       "  '\\n',\n",
       "  '    def _restore_input(self):\\n',\n",
       "  '        \"\"\"Restore raw_input, getpass\"\"\"\\n',\n",
       "  '        if PY3:\\n',\n",
       "  '            builtin_mod.input = self._sys_raw_input\\n',\n",
       "  '        else:\\n',\n",
       "  '            builtin_mod.raw_input = self._sys_raw_input\\n',\n",
       "  '            builtin_mod.input = self._sys_eval_input\\n',\n",
       "  '\\n',\n",
       "  '        getpass.getpass = self._save_getpass\\n',\n",
       "  '\\n',\n",
       "  '    @property\\n',\n",
       "  '    def execution_count(self):\\n',\n",
       "  '        return self.shell.execution_count\\n',\n",
       "  '\\n',\n",
       "  '    @execution_count.setter\\n',\n",
       "  '    def execution_count(self, value):\\n',\n",
       "  \"        # Ignore the incrememnting done by KernelBase, in favour of our shell's\\n\",\n",
       "  '        # execution counter.\\n',\n",
       "  '        pass\\n',\n",
       "  '\\n',\n",
       "  '    def do_execute(self, code, silent, store_history=True,\\n',\n",
       "  '                   user_expressions=None, allow_stdin=False):\\n',\n",
       "  \"        shell = self.shell # we'll need this a lot here\\n\",\n",
       "  '\\n',\n",
       "  '        self._forward_input(allow_stdin)\\n',\n",
       "  '\\n',\n",
       "  '        reply_content = {}\\n',\n",
       "  '        # FIXME: the shell calls the exception handler itself.\\n',\n",
       "  '        shell._reply_content = None\\n',\n",
       "  '        try:\\n',\n",
       "  '            shell.run_cell(code, store_history=store_history, silent=silent)\\n',\n",
       "  '        except:\\n',\n",
       "  \"            status = u'error'\\n\",\n",
       "  \"            # FIXME: this code right now isn't being used yet by default,\\n\",\n",
       "  '            # because the run_cell() call above directly fires off exception\\n',\n",
       "  '            # reporting.  This code, therefore, is only active in the scenario\\n',\n",
       "  '            # where runlines itself has an unhandled exception.  We need to\\n',\n",
       "  '            # uniformize this, for all exception construction to come from a\\n',\n",
       "  '            # single location in the codbase.\\n',\n",
       "  '            etype, evalue, tb = sys.exc_info()\\n',\n",
       "  '            tb_list = traceback.format_exception(etype, evalue, tb)\\n',\n",
       "  '            reply_content.update(shell._showtraceback(etype, evalue, tb_list))\\n',\n",
       "  '        else:\\n',\n",
       "  \"            status = u'ok'\\n\",\n",
       "  '        finally:\\n',\n",
       "  '            self._restore_input()\\n',\n",
       "  '\\n',\n",
       "  \"        reply_content[u'status'] = status\\n\",\n",
       "  '\\n',\n",
       "  '        # Return the execution counter so clients can display prompts\\n',\n",
       "  \"        reply_content['execution_count'] = shell.execution_count - 1\\n\",\n",
       "  '\\n',\n",
       "  '        # FIXME - fish exception info out of shell, possibly left there by\\n',\n",
       "  \"        # runlines.  We'll need to clean up this logic later.\\n\",\n",
       "  '        if shell._reply_content is not None:\\n',\n",
       "  '            reply_content.update(shell._reply_content)\\n',\n",
       "  '            # reset after use\\n',\n",
       "  '            shell._reply_content = None\\n',\n",
       "  '            # FIXME: deprecate piece for ipyparallel:\\n',\n",
       "  \"            e_info = dict(engine_uuid=self.ident, engine_id=self.int_id, method='execute')\\n\",\n",
       "  \"            reply_content['engine_info'] = e_info\\n\",\n",
       "  '\\n',\n",
       "  \"        if 'traceback' in reply_content:\\n\",\n",
       "  '            self.log.info(\"Exception in execute request:\\\\n%s\", \\'\\\\n\\'.join(reply_content[\\'traceback\\']))\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '        # At this point, we can tell whether the main code execution succeeded\\n',\n",
       "  '        # or not.  If it did, we proceed to evaluate user_expressions\\n',\n",
       "  \"        if reply_content['status'] == 'ok':\\n\",\n",
       "  \"            reply_content[u'user_expressions'] = \\\\\\n\",\n",
       "  '                         shell.user_expressions(user_expressions or {})\\n',\n",
       "  '        else:\\n',\n",
       "  \"            # If there was an error, don't even try to compute expressions\\n\",\n",
       "  \"            reply_content[u'user_expressions'] = {}\\n\",\n",
       "  '\\n',\n",
       "  '        # Payloads should be retrieved regardless of outcome, so we can both\\n',\n",
       "  '        # recover partial output (that could have been generated early in a\\n',\n",
       "  '        # block, before an error) and clear the payload system always.\\n',\n",
       "  \"        reply_content[u'payload'] = shell.payload_manager.read_payload()\\n\",\n",
       "  \"        # Be agressive about clearing the payload because we don't want\\n\",\n",
       "  '        # it to sit in memory until the next execute_request comes in.\\n',\n",
       "  '        shell.payload_manager.clear_payload()\\n',\n",
       "  '\\n',\n",
       "  '        return reply_content\\n',\n",
       "  '\\n',\n",
       "  '    def do_complete(self, code, cursor_pos):\\n',\n",
       "  '        # FIXME: IPython completers currently assume single line,\\n',\n",
       "  '        # but completion messages give multi-line context\\n',\n",
       "  '        # For now, extract line from cell, based on cursor_pos:\\n',\n",
       "  '        if cursor_pos is None:\\n',\n",
       "  '            cursor_pos = len(code)\\n',\n",
       "  '        line, offset = line_at_cursor(code, cursor_pos)\\n',\n",
       "  '        line_cursor = cursor_pos - offset\\n',\n",
       "  '\\n',\n",
       "  \"        txt, matches = self.shell.complete('', line, line_cursor)\\n\",\n",
       "  \"        return {'matches' : matches,\\n\",\n",
       "  \"                'cursor_end' : cursor_pos,\\n\",\n",
       "  \"                'cursor_start' : cursor_pos - len(txt),\\n\",\n",
       "  \"                'metadata' : {},\\n\",\n",
       "  \"                'status' : 'ok'}\\n\",\n",
       "  '\\n',\n",
       "  '    def do_inspect(self, code, cursor_pos, detail_level=0):\\n',\n",
       "  '        name = token_at_cursor(code, cursor_pos)\\n',\n",
       "  '        info = self.shell.object_inspect(name)\\n',\n",
       "  '\\n',\n",
       "  \"        reply_content = {'status' : 'ok'}\\n\",\n",
       "  \"        reply_content['data'] = data = {}\\n\",\n",
       "  \"        reply_content['metadata'] = {}\\n\",\n",
       "  \"        reply_content['found'] = info['found']\\n\",\n",
       "  \"        if info['found']:\\n\",\n",
       "  '            info_text = self.shell.object_inspect_text(\\n',\n",
       "  '                name,\\n',\n",
       "  '                detail_level=detail_level,\\n',\n",
       "  '            )\\n',\n",
       "  \"            data['text/plain'] = info_text\\n\",\n",
       "  '\\n',\n",
       "  '        return reply_content\\n',\n",
       "  '\\n',\n",
       "  '    def do_history(self, hist_access_type, output, raw, session=None, start=None,\\n',\n",
       "  '                   stop=None, n=None, pattern=None, unique=False):\\n',\n",
       "  \"        if hist_access_type == 'tail':\\n\",\n",
       "  '            hist = self.shell.history_manager.get_tail(n, raw=raw, output=output,\\n',\n",
       "  '                                                            include_latest=True)\\n',\n",
       "  '\\n',\n",
       "  \"        elif hist_access_type == 'range':\\n\",\n",
       "  '            hist = self.shell.history_manager.get_range(session, start, stop,\\n',\n",
       "  '                                                        raw=raw, output=output)\\n',\n",
       "  '\\n',\n",
       "  \"        elif hist_access_type == 'search':\\n\",\n",
       "  '            hist = self.shell.history_manager.search(\\n',\n",
       "  '                pattern, raw=raw, output=output, n=n, unique=unique)\\n',\n",
       "  '        else:\\n',\n",
       "  '            hist = []\\n',\n",
       "  '\\n',\n",
       "  \"        return {'history' : list(hist)}\\n\",\n",
       "  '\\n',\n",
       "  '    def do_shutdown(self, restart):\\n',\n",
       "  '        self.shell.exit_now = True\\n',\n",
       "  \"        return dict(status='ok', restart=restart)\\n\",\n",
       "  '\\n',\n",
       "  '    def do_is_complete(self, code):\\n',\n",
       "  '        status, indent_spaces = self.shell.input_transformer_manager.check_complete(code)\\n',\n",
       "  \"        r = {'status': status}\\n\",\n",
       "  \"        if status == 'incomplete':\\n\",\n",
       "  \"            r['indent'] = ' ' * indent_spaces\\n\",\n",
       "  '        return r\\n',\n",
       "  '\\n',\n",
       "  '    def do_apply(self, content, bufs, msg_id, reply_metadata):\\n',\n",
       "  '        from .serialize import serialize_object, unpack_apply_message\\n',\n",
       "  '        shell = self.shell\\n',\n",
       "  '        try:\\n',\n",
       "  '            working = shell.user_ns\\n',\n",
       "  '\\n',\n",
       "  '            prefix = \"_\"+str(msg_id).replace(\"-\",\"\")+\"_\"\\n',\n",
       "  '\\n',\n",
       "  '            f,args,kwargs = unpack_apply_message(bufs, working, copy=False)\\n',\n",
       "  '\\n',\n",
       "  \"            fname = getattr(f, '__name__', 'f')\\n\",\n",
       "  '\\n',\n",
       "  '            fname = prefix+\"f\"\\n',\n",
       "  '            argname = prefix+\"args\"\\n',\n",
       "  '            kwargname = prefix+\"kwargs\"\\n',\n",
       "  '            resultname = prefix+\"result\"\\n',\n",
       "  '\\n',\n",
       "  '            ns = { fname : f, argname : args, kwargname : kwargs , resultname : None }\\n',\n",
       "  '            # print ns\\n',\n",
       "  '            working.update(ns)\\n',\n",
       "  '            code = \"%s = %s(*%s,**%s)\" % (resultname, fname, argname, kwargname)\\n',\n",
       "  '            try:\\n',\n",
       "  '                exec(code, shell.user_global_ns, shell.user_ns)\\n',\n",
       "  '                result = working.get(resultname)\\n',\n",
       "  '            finally:\\n',\n",
       "  '                for key in ns:\\n',\n",
       "  '                    working.pop(key)\\n',\n",
       "  '\\n',\n",
       "  '            result_buf = serialize_object(result,\\n',\n",
       "  '                buffer_threshold=self.session.buffer_threshold,\\n',\n",
       "  '                item_threshold=self.session.item_threshold,\\n',\n",
       "  '            )\\n',\n",
       "  '\\n',\n",
       "  '        except:\\n',\n",
       "  '            # invoke IPython traceback formatting\\n',\n",
       "  '            shell.showtraceback()\\n',\n",
       "  '            # FIXME - fish exception info out of shell, possibly left there by\\n',\n",
       "  \"            # run_code.  We'll need to clean up this logic later.\\n\",\n",
       "  '            reply_content = {}\\n',\n",
       "  '            if shell._reply_content is not None:\\n',\n",
       "  '                reply_content.update(shell._reply_content)\\n',\n",
       "  '                # reset after use\\n',\n",
       "  '                shell._reply_content = None\\n',\n",
       "  '                \\n',\n",
       "  '                # FIXME: deprecate piece for ipyparallel:\\n',\n",
       "  \"                e_info = dict(engine_uuid=self.ident, engine_id=self.int_id, method='apply')\\n\",\n",
       "  \"                reply_content['engine_info'] = e_info\\n\",\n",
       "  '\\n',\n",
       "  \"            self.send_response(self.iopub_socket, u'error', reply_content,\\n\",\n",
       "  \"                                ident=self._topic('error'))\\n\",\n",
       "  '            self.log.info(\"Exception in apply request:\\\\n%s\", \\'\\\\n\\'.join(reply_content[\\'traceback\\']))\\n',\n",
       "  '            result_buf = []\\n',\n",
       "  '        else:\\n',\n",
       "  \"            reply_content = {'status' : 'ok'}\\n\",\n",
       "  '\\n',\n",
       "  '        return reply_content, result_buf\\n',\n",
       "  '\\n',\n",
       "  '    def do_clear(self):\\n',\n",
       "  '        self.shell.reset(False)\\n',\n",
       "  \"        return dict(status='ok')\\n\",\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '# This exists only for backwards compatibility - use IPythonKernel instead\\n',\n",
       "  '\\n',\n",
       "  'class Kernel(IPythonKernel):\\n',\n",
       "  '    def __init__(self, *args, **kwargs):\\n',\n",
       "  '        import warnings\\n',\n",
       "  \"        warnings.warn('Kernel is a deprecated alias of ipykernel.ipkernel.IPythonKernel',\\n\",\n",
       "  '                      DeprecationWarning)\\n',\n",
       "  '        super(Kernel, self).__init__(*args, **kwargs)\\n'],\n",
       " <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " <bound method IPythonKernel.execute_request of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " ['\"\"\"A ZMQ-based subclass of InteractiveShell.\\n',\n",
       "  '\\n',\n",
       "  'This code is meant to ease the refactoring of the base InteractiveShell into\\n',\n",
       "  'something with a cleaner architecture for 2-process use, without actually\\n',\n",
       "  \"breaking InteractiveShell itself.  So we're doing something a bit ugly, where\\n\",\n",
       "  'we subclass and override what we want to fix.  Once this is working well, we\\n',\n",
       "  'can go back to the base class and refactor the code for a cleaner inheritance\\n',\n",
       "  \"implementation that doesn't rely on so much monkeypatching.\\n\",\n",
       "  '\\n',\n",
       "  'But this lets us maintain a fully working IPython as we develop the new\\n',\n",
       "  'machinery.  This should thus be thought of as scaffolding.\\n',\n",
       "  '\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '# Copyright (c) IPython Development Team.\\n',\n",
       "  '# Distributed under the terms of the Modified BSD License.\\n',\n",
       "  '\\n',\n",
       "  'from __future__ import print_function\\n',\n",
       "  '\\n',\n",
       "  'import os\\n',\n",
       "  'import sys\\n',\n",
       "  'import time\\n',\n",
       "  'import warnings\\n',\n",
       "  '\\n',\n",
       "  'from zmq.eventloop import ioloop\\n',\n",
       "  '\\n',\n",
       "  'from IPython.core.interactiveshell import (\\n',\n",
       "  '    InteractiveShell, InteractiveShellABC\\n',\n",
       "  ')\\n',\n",
       "  'from IPython.core import page\\n',\n",
       "  'from IPython.core.autocall import ZMQExitAutocall\\n',\n",
       "  'from IPython.core.displaypub import DisplayPublisher\\n',\n",
       "  'from IPython.core.error import UsageError\\n',\n",
       "  'from IPython.core.magics import MacroToEdit, CodeMagics\\n',\n",
       "  'from IPython.core.magic import magics_class, line_magic, Magics\\n',\n",
       "  'from IPython.core import payloadpage\\n',\n",
       "  'from IPython.core.usage import default_banner\\n',\n",
       "  'from IPython.display import display, Javascript\\n',\n",
       "  'from ipykernel import (\\n',\n",
       "  '    get_connection_file, get_connection_info, connect_qtconsole\\n',\n",
       "  ')\\n',\n",
       "  'from IPython.utils import openpy\\n',\n",
       "  'from ipykernel.jsonutil import json_clean, encode_images\\n',\n",
       "  'from IPython.utils.process import arg_split\\n',\n",
       "  'from ipython_genutils import py3compat\\n',\n",
       "  'from ipython_genutils.py3compat import unicode_type\\n',\n",
       "  'from traitlets import Instance, Type, Dict, CBool, CBytes, Any\\n',\n",
       "  'from IPython.utils.warn import error\\n',\n",
       "  'from ipykernel.displayhook import ZMQShellDisplayHook\\n',\n",
       "  'from jupyter_client.session import extract_header\\n',\n",
       "  'from jupyter_client.session import Session\\n',\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '# Functions and classes\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  'class ZMQDisplayPublisher(DisplayPublisher):\\n',\n",
       "  '    \"\"\"A display publisher that publishes data using a ZeroMQ PUB socket.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    session = Instance(Session, allow_none=True)\\n',\n",
       "  '    pub_socket = Any(allow_none=True)\\n',\n",
       "  '    parent_header = Dict({})\\n',\n",
       "  \"    topic = CBytes(b'display_data')\\n\",\n",
       "  '\\n',\n",
       "  '    def set_parent(self, parent):\\n',\n",
       "  '        \"\"\"Set the parent for outbound messages.\"\"\"\\n',\n",
       "  '        self.parent_header = extract_header(parent)\\n',\n",
       "  '\\n',\n",
       "  '    def _flush_streams(self):\\n',\n",
       "  '        \"\"\"flush IO Streams prior to display\"\"\"\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  '\\n',\n",
       "  '    def publish(self, data, metadata=None, source=None):\\n',\n",
       "  '        self._flush_streams()\\n',\n",
       "  '        if metadata is None:\\n',\n",
       "  '            metadata = {}\\n',\n",
       "  '        self._validate_data(data, metadata)\\n',\n",
       "  '        content = {}\\n',\n",
       "  \"        content['data'] = encode_images(data)\\n\",\n",
       "  \"        content['metadata'] = metadata\\n\",\n",
       "  '        self.session.send(\\n',\n",
       "  \"            self.pub_socket, u'display_data', json_clean(content),\\n\",\n",
       "  '            parent=self.parent_header, ident=self.topic,\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '    def clear_output(self, wait=False):\\n',\n",
       "  '        content = dict(wait=wait)\\n',\n",
       "  '        self._flush_streams()\\n',\n",
       "  '        self.session.send(\\n',\n",
       "  \"            self.pub_socket, u'clear_output', content,\\n\",\n",
       "  '            parent=self.parent_header, ident=self.topic,\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '@magics_class\\n',\n",
       "  'class KernelMagics(Magics):\\n',\n",
       "  '    #------------------------------------------------------------------------\\n',\n",
       "  '    # Magic overrides\\n',\n",
       "  '    #------------------------------------------------------------------------\\n',\n",
       "  '    # Once the base class stops inheriting from magic, this code needs to be\\n',\n",
       "  '    # moved into a separate machinery as well.  For now, at least isolate here\\n',\n",
       "  '    # the magics which this class needs to implement differently from the base\\n',\n",
       "  '    # class, or that are unique to it.\\n',\n",
       "  '\\n',\n",
       "  '    _find_edit_target = CodeMagics._find_edit_target\\n',\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  \"    def edit(self, parameter_s='', last_call=['','']):\\n\",\n",
       "  '        \"\"\"Bring up an editor and execute the resulting code.\\n',\n",
       "  '\\n',\n",
       "  '        Usage:\\n',\n",
       "  '          %edit [options] [args]\\n',\n",
       "  '\\n',\n",
       "  '        %edit runs an external text editor. You will need to set the command for\\n',\n",
       "  '        this editor via the ``TerminalInteractiveShell.editor`` option in your\\n',\n",
       "  '        configuration file before it will work.\\n',\n",
       "  '\\n',\n",
       "  '        This command allows you to conveniently edit multi-line code right in\\n',\n",
       "  '        your IPython session.\\n',\n",
       "  '\\n',\n",
       "  '        If called without arguments, %edit opens up an empty editor with a\\n',\n",
       "  '        temporary file and will execute the contents of this file when you\\n',\n",
       "  \"        close it (don't forget to save it!).\\n\",\n",
       "  '\\n',\n",
       "  '        Options:\\n',\n",
       "  '\\n',\n",
       "  '        -n <number>\\n',\n",
       "  '          Open the editor at a specified line number. By default, the IPython\\n',\n",
       "  \"          editor hook uses the unix syntax 'editor +N filename', but you can\\n\",\n",
       "  '          configure this by providing your own modified hook if your favorite\\n',\n",
       "  '          editor supports line-number specifications with a different syntax.\\n',\n",
       "  '\\n',\n",
       "  '        -p\\n',\n",
       "  '          Call the editor with the same data as the previous time it was used,\\n',\n",
       "  '          regardless of how long ago (in your current session) it was.\\n',\n",
       "  '\\n',\n",
       "  '        -r\\n',\n",
       "  \"          Use 'raw' input. This option only applies to input taken from the\\n\",\n",
       "  \"          user's history.  By default, the 'processed' history is used, so that\\n\",\n",
       "  '          magics are loaded in their transformed version to valid Python.  If\\n',\n",
       "  '          this option is given, the raw input as typed as the command line is\\n',\n",
       "  '          used instead.  When you exit the editor, it will be executed by\\n',\n",
       "  \"          IPython's own processor.\\n\",\n",
       "  '\\n',\n",
       "  '        Arguments:\\n',\n",
       "  '\\n',\n",
       "  '        If arguments are given, the following possibilites exist:\\n',\n",
       "  '\\n',\n",
       "  '        - The arguments are numbers or pairs of colon-separated numbers (like\\n',\n",
       "  '          1 4:8 9). These are interpreted as lines of previous input to be\\n',\n",
       "  '          loaded into the editor. The syntax is the same of the %macro command.\\n',\n",
       "  '\\n',\n",
       "  \"        - If the argument doesn't start with a number, it is evaluated as a\\n\",\n",
       "  '          variable and its contents loaded into the editor. You can thus edit\\n',\n",
       "  '          any string which contains python code (including the result of\\n',\n",
       "  '          previous edits).\\n',\n",
       "  '\\n',\n",
       "  '        - If the argument is the name of an object (other than a string),\\n',\n",
       "  '          IPython will try to locate the file where it was defined and open the\\n',\n",
       "  '          editor at the point where it is defined. You can use ``%edit function``\\n',\n",
       "  \"          to load an editor exactly at the point where 'function' is defined,\\n\",\n",
       "  '          edit it and have the file be executed automatically.\\n',\n",
       "  '\\n',\n",
       "  '          If the object is a macro (see %macro for details), this opens up your\\n',\n",
       "  \"          specified editor with a temporary file containing the macro's data.\\n\",\n",
       "  '          Upon exit, the macro is reloaded with the contents of the file.\\n',\n",
       "  '\\n',\n",
       "  '          Note: opening at an exact line is only supported under Unix, and some\\n',\n",
       "  '          editors (like kedit and gedit up to Gnome 2.8) do not understand the\\n',\n",
       "  \"          '+NUMBER' parameter necessary for this feature. Good editors like\\n\",\n",
       "  '          (X)Emacs, vi, jed, pico and joe all do.\\n',\n",
       "  '\\n',\n",
       "  '        - If the argument is not found as a variable, IPython will look for a\\n',\n",
       "  '          file with that name (adding .py if necessary) and load it into the\\n',\n",
       "  '          editor. It will execute its contents with execfile() when you exit,\\n',\n",
       "  '          loading any code in the file into your interactive namespace.\\n',\n",
       "  '\\n',\n",
       "  '        Unlike in the terminal, this is designed to use a GUI editor, and we do\\n',\n",
       "  '        not know when it has closed. So the file you edit will not be\\n',\n",
       "  '        automatically executed or printed.\\n',\n",
       "  '\\n',\n",
       "  '        Note that %edit is also available through the alias %ed.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '\\n',\n",
       "  \"        opts,args = self.parse_options(parameter_s,'prn:')\\n\",\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  '            filename, lineno, _ = CodeMagics._find_edit_target(self.shell, args, opts, last_call)\\n',\n",
       "  '        except MacroToEdit as e:\\n',\n",
       "  '            # TODO: Implement macro editing over 2 processes.\\n',\n",
       "  '            print(\"Macro editing not yet implemented in 2-process model.\")\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        # Make sure we send to the client an absolute path, in case the working\\n',\n",
       "  \"        # directory of client and kernel don't match\\n\",\n",
       "  '        filename = os.path.abspath(filename)\\n',\n",
       "  '\\n',\n",
       "  '        payload = {\\n',\n",
       "  \"            'source' : 'edit_magic',\\n\",\n",
       "  \"            'filename' : filename,\\n\",\n",
       "  \"            'line_number' : lineno\\n\",\n",
       "  '        }\\n',\n",
       "  '        self.shell.payload_manager.write_payload(payload)\\n',\n",
       "  '\\n',\n",
       "  '    # A few magics that are adapted to the specifics of using pexpect and a\\n',\n",
       "  '    # remote terminal\\n',\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  '    def clear(self, arg_s):\\n',\n",
       "  '        \"\"\"Clear the terminal.\"\"\"\\n',\n",
       "  \"        if os.name == 'posix':\\n\",\n",
       "  '            self.shell.system(\"clear\")\\n',\n",
       "  '        else:\\n',\n",
       "  '            self.shell.system(\"cls\")\\n',\n",
       "  '\\n',\n",
       "  \"    if os.name == 'nt':\\n\",\n",
       "  '        # This is the usual name in windows\\n',\n",
       "  \"        cls = line_magic('cls')(clear)\\n\",\n",
       "  '\\n',\n",
       "  \"    # Terminal pagers won't work over pexpect, but we do have our own pager\\n\",\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  '    def less(self, arg_s):\\n',\n",
       "  '        \"\"\"Show a file through the pager.\\n',\n",
       "  '\\n',\n",
       "  '        Files ending in .py are syntax-highlighted.\"\"\"\\n',\n",
       "  '        if not arg_s:\\n',\n",
       "  \"            raise UsageError('Missing filename.')\\n\",\n",
       "  '\\n',\n",
       "  \"        if arg_s.endswith('.py'):\\n\",\n",
       "  '            cont = self.shell.pycolorize(openpy.read_py_file(arg_s, skip_encoding_cookie=False))\\n',\n",
       "  '        else:\\n',\n",
       "  '            cont = open(arg_s).read()\\n',\n",
       "  '        page.page(cont)\\n',\n",
       "  '\\n',\n",
       "  \"    more = line_magic('more')(less)\\n\",\n",
       "  '\\n',\n",
       "  '    # Man calls a pager, so we also need to redefine it\\n',\n",
       "  \"    if os.name == 'posix':\\n\",\n",
       "  '        @line_magic\\n',\n",
       "  '        def man(self, arg_s):\\n',\n",
       "  '            \"\"\"Find the man page for the given command and display in pager.\"\"\"\\n',\n",
       "  \"            page.page(self.shell.getoutput('man %s | col -b' % arg_s,\\n\",\n",
       "  '                                           split=False))\\n',\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  '    def connect_info(self, arg_s):\\n',\n",
       "  '        \"\"\"Print information for connecting other clients to this kernel\\n',\n",
       "  '\\n',\n",
       "  \"        It will print the contents of this session's connection file, as well as\\n\",\n",
       "  '        shortcuts for local clients.\\n',\n",
       "  '\\n',\n",
       "  '        In the simplest case, when called from the most recently launched kernel,\\n',\n",
       "  '        secondary clients can be connected, simply with:\\n',\n",
       "  '\\n',\n",
       "  '        $> ipython <app> --existing\\n',\n",
       "  '\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        from IPython.core.application import BaseIPythonApplication as BaseIPApp\\n',\n",
       "  '\\n',\n",
       "  '        if BaseIPApp.initialized():\\n',\n",
       "  '            app = BaseIPApp.instance()\\n',\n",
       "  '            security_dir = app.profile_dir.security_dir\\n',\n",
       "  '            profile = app.profile\\n',\n",
       "  '        else:\\n',\n",
       "  \"            profile = 'default'\\n\",\n",
       "  \"            security_dir = ''\\n\",\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  '            connection_file = get_connection_file()\\n',\n",
       "  '            info = get_connection_info(unpack=False)\\n',\n",
       "  '        except Exception as e:\\n',\n",
       "  '            error(\"Could not get connection info: %r\" % e)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        # add profile flag for non-default profile\\n',\n",
       "  '        profile_flag = \"--profile %s\" % profile if profile != \\'default\\' else \"\"\\n',\n",
       "  '\\n',\n",
       "  \"        # if it's in the security dir, truncate to basename\\n\",\n",
       "  '        if security_dir == os.path.dirname(connection_file):\\n',\n",
       "  '            connection_file = os.path.basename(connection_file)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  \"        print (info + '\\\\n')\\n\",\n",
       "  '        print (\"Paste the above JSON into a file, and connect with:\\\\n\"\\n',\n",
       "  '            \"    $> ipython <app> --existing <file>\\\\n\"\\n',\n",
       "  '            \"or, if you are local, you can connect with just:\\\\n\"\\n',\n",
       "  '            \"    $> ipython <app> --existing {0} {1}\\\\n\"\\n',\n",
       "  '            \"or even just:\\\\n\"\\n',\n",
       "  '            \"    $> ipython <app> --existing {1}\\\\n\"\\n',\n",
       "  '            \"if this is the most recent IPython session you have started.\".format(\\n',\n",
       "  '            connection_file, profile_flag\\n',\n",
       "  '            )\\n',\n",
       "  '        )\\n',\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  '    def qtconsole(self, arg_s):\\n',\n",
       "  '        \"\"\"Open a qtconsole connected to this kernel.\\n',\n",
       "  '\\n',\n",
       "  '        Useful for connecting a qtconsole to running notebooks, for better\\n',\n",
       "  '        debugging.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        # %qtconsole should imply bind_kernel for engines:\\n',\n",
       "  '        # FIXME: move to ipyparallel Kernel subclass\\n',\n",
       "  \"        if 'ipyparallel' in sys.modules:\\n\",\n",
       "  '            from ipyparallel import bind_kernel\\n',\n",
       "  '            bind_kernel()\\n',\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  \"            p = connect_qtconsole(argv=arg_split(arg_s, os.name=='posix'))\\n\",\n",
       "  '        except Exception as e:\\n',\n",
       "  '            error(\"Could not start qtconsole: %r\" % e)\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '    @line_magic\\n',\n",
       "  '    def autosave(self, arg_s):\\n',\n",
       "  '        \"\"\"Set the autosave interval in the notebook (in seconds).\\n',\n",
       "  '\\n',\n",
       "  '        The default value is 120, or two minutes.\\n',\n",
       "  '        ``%autosave 0`` will disable autosave.\\n',\n",
       "  '\\n',\n",
       "  '        This magic only has an effect when called from the notebook interface.\\n',\n",
       "  '        It has no effect when called in a startup file.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  '            interval = int(arg_s)\\n',\n",
       "  '        except ValueError:\\n',\n",
       "  '            raise UsageError(\"%%autosave requires an integer, got %r\" % arg_s)\\n',\n",
       "  '\\n',\n",
       "  '        # javascript wants milliseconds\\n',\n",
       "  '        milliseconds = 1000 * interval\\n',\n",
       "  '        display(Javascript(\"IPython.notebook.set_autosave_interval(%i)\" % milliseconds),\\n',\n",
       "  \"            include=['application/javascript']\\n\",\n",
       "  '        )\\n',\n",
       "  '        if interval:\\n',\n",
       "  '            print(\"Autosaving every %i seconds\" % interval)\\n',\n",
       "  '        else:\\n',\n",
       "  '            print(\"Autosave disabled\")\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class ZMQInteractiveShell(InteractiveShell):\\n',\n",
       "  '    \"\"\"A subclass of InteractiveShell for ZMQ.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    displayhook_class = Type(ZMQShellDisplayHook)\\n',\n",
       "  '    display_pub_class = Type(ZMQDisplayPublisher)\\n',\n",
       "  \"    data_pub_class = Type('ipykernel.datapub.ZMQDataPublisher')\\n\",\n",
       "  '    kernel = Any()\\n',\n",
       "  '    parent_header = Any()\\n',\n",
       "  '\\n',\n",
       "  '    def _banner1_default(self):\\n',\n",
       "  '        return default_banner\\n',\n",
       "  '\\n',\n",
       "  \"    # Override the traitlet in the parent class, because there's no point using\\n\",\n",
       "  '    # readline for the kernel. Can be removed when the readline code is moved\\n',\n",
       "  '    # to the terminal frontend.\\n',\n",
       "  '    colors_force = CBool(True)\\n',\n",
       "  '    readline_use = CBool(False)\\n',\n",
       "  '    # autoindent has no meaning in a zmqshell, and attempting to enable it\\n',\n",
       "  '    # will print a warning in the absence of readline.\\n',\n",
       "  '    autoindent = CBool(False)\\n',\n",
       "  '\\n',\n",
       "  '    exiter = Instance(ZMQExitAutocall)\\n',\n",
       "  '    def _exiter_default(self):\\n',\n",
       "  '        return ZMQExitAutocall(self)\\n',\n",
       "  '\\n',\n",
       "  '    def _exit_now_changed(self, name, old, new):\\n',\n",
       "  '        \"\"\"stop eventloop when exit_now fires\"\"\"\\n',\n",
       "  '        if new:\\n',\n",
       "  '            loop = ioloop.IOLoop.instance()\\n',\n",
       "  '            loop.add_timeout(time.time()+0.1, loop.stop)\\n',\n",
       "  '\\n',\n",
       "  '    keepkernel_on_exit = None\\n',\n",
       "  '\\n',\n",
       "  \"    # Over ZeroMQ, GUI control isn't done with PyOS_InputHook as there is no\\n\",\n",
       "  '    # interactive input being read; we provide event loop support in ipkernel\\n',\n",
       "  '    @staticmethod\\n',\n",
       "  '    def enable_gui(gui):\\n',\n",
       "  '        from .eventloops import enable_gui as real_enable_gui\\n',\n",
       "  '        try:\\n',\n",
       "  '            real_enable_gui(gui)\\n',\n",
       "  '        except ValueError as e:\\n',\n",
       "  '            raise UsageError(\"%s\" % e)\\n',\n",
       "  '\\n',\n",
       "  '    def init_environment(self):\\n',\n",
       "  '        \"\"\"Configure the user\\'s environment.\"\"\"\\n',\n",
       "  '        env = os.environ\\n',\n",
       "  \"        # These two ensure 'ls' produces nice coloring on BSD-derived systems\\n\",\n",
       "  \"        env['TERM'] = 'xterm-color'\\n\",\n",
       "  \"        env['CLICOLOR'] = '1'\\n\",\n",
       "  \"        # Since normal pagers don't work at all (over pexpect we don't have\\n\",\n",
       "  '        # single-key control of the subprocess), try to disable paging in\\n',\n",
       "  '        # subprocesses as much as possible.\\n',\n",
       "  \"        env['PAGER'] = 'cat'\\n\",\n",
       "  \"        env['GIT_PAGER'] = 'cat'\\n\",\n",
       "  '\\n',\n",
       "  '    def init_hooks(self):\\n',\n",
       "  '        super(ZMQInteractiveShell, self).init_hooks()\\n',\n",
       "  \"        self.set_hook('show_in_pager', page.as_hook(payloadpage.page), 99)\\n\",\n",
       "  '    \\n',\n",
       "  '    def init_data_pub(self):\\n',\n",
       "  '        \"\"\"Delay datapub init until request, for deprecation warnings\"\"\"\\n',\n",
       "  '        pass\\n',\n",
       "  '    \\n',\n",
       "  '    @property\\n',\n",
       "  '    def data_pub(self):\\n',\n",
       "  \"        if not hasattr(self, '_data_pub'):\\n\",\n",
       "  '            warnings.warn(\"InteractiveShell.data_pub is deprecated outside IPython parallel.\", \\n',\n",
       "  '                DeprecationWarning, stacklevel=2)\\n',\n",
       "  '            \\n',\n",
       "  '            self._data_pub = self.data_pub_class(parent=self)\\n',\n",
       "  '            self._data_pub.session = self.display_pub.session\\n',\n",
       "  '            self._data_pub.pub_socket = self.display_pub.pub_socket\\n',\n",
       "  '        return self._data_pub\\n',\n",
       "  '    \\n',\n",
       "  '    @data_pub.setter\\n',\n",
       "  '    def data_pub(self, pub):\\n',\n",
       "  '        self._data_pub = pub\\n',\n",
       "  '\\n',\n",
       "  '    def ask_exit(self):\\n',\n",
       "  '        \"\"\"Engage the exit actions.\"\"\"\\n',\n",
       "  '        self.exit_now = (not self.keepkernel_on_exit)\\n',\n",
       "  '        payload = dict(\\n',\n",
       "  \"            source='ask_exit',\\n\",\n",
       "  '            keepkernel=self.keepkernel_on_exit,\\n',\n",
       "  '            )\\n',\n",
       "  '        self.payload_manager.write_payload(payload)\\n',\n",
       "  '\\n',\n",
       "  '    def _showtraceback(self, etype, evalue, stb):\\n',\n",
       "  '        # try to preserve ordering of tracebacks and print statements\\n',\n",
       "  '        sys.stdout.flush()\\n',\n",
       "  '        sys.stderr.flush()\\n',\n",
       "  '\\n',\n",
       "  '        exc_content = {\\n',\n",
       "  \"            u'traceback' : stb,\\n\",\n",
       "  \"            u'ename' : unicode_type(etype.__name__),\\n\",\n",
       "  \"            u'evalue' : py3compat.safe_unicode(evalue),\\n\",\n",
       "  '        }\\n',\n",
       "  '\\n',\n",
       "  '        dh = self.displayhook\\n',\n",
       "  '        # Send exception info over pub socket for other clients than the caller\\n',\n",
       "  '        # to pick up\\n',\n",
       "  '        topic = None\\n',\n",
       "  '        if dh.topic:\\n',\n",
       "  \"            topic = dh.topic.replace(b'execute_result', b'error')\\n\",\n",
       "  '\\n',\n",
       "  \"        exc_msg = dh.session.send(dh.pub_socket, u'error', json_clean(exc_content), dh.parent_header, ident=topic)\\n\",\n",
       "  '\\n',\n",
       "  '        # FIXME - Hack: store exception info in shell object.  Right now, the\\n',\n",
       "  '        # caller is reading this info after the fact, we need to fix this logic\\n',\n",
       "  '        # to remove this hack.  Even uglier, we need to store the error status\\n',\n",
       "  '        # here, because in the main loop, the logic that sets it is being\\n',\n",
       "  '        # skipped because runlines swallows the exceptions.\\n',\n",
       "  \"        exc_content[u'status'] = u'error'\\n\",\n",
       "  '        self._reply_content = exc_content\\n',\n",
       "  '        # /FIXME\\n',\n",
       "  '\\n',\n",
       "  '        return exc_content\\n',\n",
       "  '\\n',\n",
       "  '    def set_next_input(self, text, replace=False):\\n',\n",
       "  '        \"\"\"Send the specified text to the frontend to be presented at the next\\n',\n",
       "  '        input cell.\"\"\"\\n',\n",
       "  '        payload = dict(\\n',\n",
       "  \"            source='set_next_input',\\n\",\n",
       "  '            text=text,\\n',\n",
       "  '            replace=replace,\\n',\n",
       "  '        )\\n',\n",
       "  '        self.payload_manager.write_payload(payload)\\n',\n",
       "  '\\n',\n",
       "  '    def set_parent(self, parent):\\n',\n",
       "  '        \"\"\"Set the parent header for associating output with its triggering input\"\"\"\\n',\n",
       "  '        self.parent_header = parent\\n',\n",
       "  '        self.displayhook.set_parent(parent)\\n',\n",
       "  '        self.display_pub.set_parent(parent)\\n',\n",
       "  \"        if hasattr(self, '_data_pub'):\\n\",\n",
       "  '            self.data_pub.set_parent(parent)\\n',\n",
       "  '        try:\\n',\n",
       "  '            sys.stdout.set_parent(parent)\\n',\n",
       "  '        except AttributeError:\\n',\n",
       "  '            pass\\n',\n",
       "  '        try:\\n',\n",
       "  '            sys.stderr.set_parent(parent)\\n',\n",
       "  '        except AttributeError:\\n',\n",
       "  '            pass\\n',\n",
       "  '\\n',\n",
       "  '    def get_parent(self):\\n',\n",
       "  '        return self.parent_header\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to magics\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def init_magics(self):\\n',\n",
       "  '        super(ZMQInteractiveShell, self).init_magics()\\n',\n",
       "  '        self.register_magics(KernelMagics)\\n',\n",
       "  \"        self.magics_manager.register_alias('ed', 'edit')\\n\",\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'InteractiveShellABC.register(ZMQInteractiveShell)\\n'],\n",
       " ModuleSpec(name='ipykernel.datapub', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b780>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/datapub.py'),\n",
       " <_frozen_importlib.SourceFileLoader at 0x7f51c124b780>,\n",
       " <_frozen_importlib.SourceFileLoader at 0x7f51c124b4a8>,\n",
       " ModuleSpec(name='ipykernel.serialize', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b4a8>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/serialize.py'),\n",
       " ModuleSpec(name='ipykernel.pickleutil', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c124b4e0>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py'),\n",
       " <_frozen_importlib.SourceFileLoader at 0x7f51c124b4e0>,\n",
       " ModuleSpec(name='ipykernel.codeutil', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c01a6278>, origin='/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py'),\n",
       " <_frozen_importlib.SourceFileLoader at 0x7f51c01a6278>,\n",
       " {'__dict__': <attribute '__dict__' of 'CannedObject' objects>,\n",
       "  '__doc__': None,\n",
       "  '__init__': <function ipykernel.pickleutil.CannedObject.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  '__weakref__': <attribute '__weakref__' of 'CannedObject' objects>,\n",
       "  'get_object': <function ipykernel.pickleutil.CannedObject.get_object>},\n",
       " {'__doc__': 'object for wrapping a remote reference by name.',\n",
       "  '__init__': <function ipykernel.pickleutil.Reference.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  '__repr__': <function ipykernel.pickleutil.Reference.__repr__>,\n",
       "  'get_object': <function ipykernel.pickleutil.Reference.get_object>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " <weakref at 0x7f51c0199c28; to 'type' at 0x55b8f537b178 (Reference)>,\n",
       " {'__doc__': 'Can a closure cell',\n",
       "  '__init__': <function ipykernel.pickleutil.CannedCell.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  'get_object': <function ipykernel.pickleutil.CannedCell.get_object>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " {'__doc__': None,\n",
       "  '__init__': <function ipykernel.pickleutil.CannedFunction.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  '_check_type': <function ipykernel.pickleutil.CannedFunction._check_type>,\n",
       "  'get_object': <function ipykernel.pickleutil.CannedFunction.get_object>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " {'__doc__': None,\n",
       "  '__init__': <function ipykernel.pickleutil.CannedClass.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  '_check_type': <function ipykernel.pickleutil.CannedClass._check_type>,\n",
       "  'get_object': <function ipykernel.pickleutil.CannedClass.get_object>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " {'__doc__': None,\n",
       "  '__init__': <function ipykernel.pickleutil.CannedArray.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  'get_object': <function ipykernel.pickleutil.CannedArray.get_object>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " {'__doc__': None,\n",
       "  '__init__': <function ipykernel.pickleutil.CannedBytes.__init__>,\n",
       "  '__module__': 'ipykernel.pickleutil',\n",
       "  'get_object': <function ipykernel.pickleutil.CannedBytes.get_object>,\n",
       "  'wrap': <staticmethod at 0x7f51c01a6438>},\n",
       " (ipykernel.pickleutil.CannedObject,),\n",
       " (ipykernel.pickleutil.CannedBytes,),\n",
       " <weakref at 0x7f51c0199e08; to 'type' at 0x55b8f537cc48 (CannedBuffer)>,\n",
       " (ipykernel.pickleutil.CannedBytes,),\n",
       " <function ipykernel.pickleutil.<lambda>>,\n",
       " {'__doc__': None,\n",
       "  '__module__': 'ipykernel.datapub',\n",
       "  '_trait_default_generators': {},\n",
       "  'parent_header': <traitlets.traitlets.Dict at 0x7f51c124b550>,\n",
       "  'pub_socket': <traitlets.traitlets.Any at 0x7f51c124b630>,\n",
       "  'publish_data': <function ipykernel.datapub.ZMQDataPublisher.publish_data>,\n",
       "  'session': <traitlets.traitlets.Instance at 0x7f51c124b5f8>,\n",
       "  'set_parent': <function ipykernel.datapub.ZMQDataPublisher.set_parent>,\n",
       "  'topic': <traitlets.traitlets.CBytes at 0x7f51c124b6d8>},\n",
       " (traitlets.config.configurable.Configurable,),\n",
       " ['# -*- coding: utf-8 -*-\\n',\n",
       "  '\"\"\"Main IPython class.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '#  Copyright (C) 2001 Janko Hauser <jhauser@zscout.de>\\n',\n",
       "  '#  Copyright (C) 2001-2007 Fernando Perez. <fperez@colorado.edu>\\n',\n",
       "  '#  Copyright (C) 2008-2011  The IPython Development Team\\n',\n",
       "  '#\\n',\n",
       "  '#  Distributed under the terms of the BSD License.  The full license is in\\n',\n",
       "  '#  the file COPYING, distributed as part of this software.\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  'from __future__ import absolute_import, print_function\\n',\n",
       "  '\\n',\n",
       "  'import __future__\\n',\n",
       "  'import abc\\n',\n",
       "  'import ast\\n',\n",
       "  'import atexit\\n',\n",
       "  'import functools\\n',\n",
       "  'import os\\n',\n",
       "  'import re\\n',\n",
       "  'import runpy\\n',\n",
       "  'import sys\\n',\n",
       "  'import tempfile\\n',\n",
       "  'import traceback\\n',\n",
       "  'import types\\n',\n",
       "  'import subprocess\\n',\n",
       "  'import warnings\\n',\n",
       "  'from io import open as io_open\\n',\n",
       "  '\\n',\n",
       "  'from pickleshare import PickleShareDB\\n',\n",
       "  '\\n',\n",
       "  'from traitlets.config.configurable import SingletonConfigurable\\n',\n",
       "  'from IPython.core import debugger, oinspect\\n',\n",
       "  'from IPython.core import magic\\n',\n",
       "  'from IPython.core import page\\n',\n",
       "  'from IPython.core import prefilter\\n',\n",
       "  'from IPython.core import shadowns\\n',\n",
       "  'from IPython.core import ultratb\\n',\n",
       "  'from IPython.core.alias import Alias, AliasManager\\n',\n",
       "  'from IPython.core.autocall import ExitAutocall\\n',\n",
       "  'from IPython.core.builtin_trap import BuiltinTrap\\n',\n",
       "  'from IPython.core.events import EventManager, available_events\\n',\n",
       "  'from IPython.core.compilerop import CachingCompiler, check_linecache_ipython\\n',\n",
       "  'from IPython.core.display_trap import DisplayTrap\\n',\n",
       "  'from IPython.core.displayhook import DisplayHook\\n',\n",
       "  'from IPython.core.displaypub import DisplayPublisher\\n',\n",
       "  'from IPython.core.error import InputRejected, UsageError\\n',\n",
       "  'from IPython.core.extensions import ExtensionManager\\n',\n",
       "  'from IPython.core.formatters import DisplayFormatter\\n',\n",
       "  'from IPython.core.history import HistoryManager\\n',\n",
       "  'from IPython.core.inputsplitter import IPythonInputSplitter, ESC_MAGIC, ESC_MAGIC2\\n',\n",
       "  'from IPython.core.logger import Logger\\n',\n",
       "  'from IPython.core.macro import Macro\\n',\n",
       "  'from IPython.core.payload import PayloadManager\\n',\n",
       "  'from IPython.core.prefilter import PrefilterManager\\n',\n",
       "  'from IPython.core.profiledir import ProfileDir\\n',\n",
       "  'from IPython.core.prompts import PromptManager\\n',\n",
       "  'from IPython.core.usage import default_banner\\n',\n",
       "  'from IPython.testing.skipdoctest import skip_doctest\\n',\n",
       "  'from IPython.utils import PyColorize\\n',\n",
       "  'from IPython.utils import io\\n',\n",
       "  'from IPython.utils import py3compat\\n',\n",
       "  'from IPython.utils import openpy\\n',\n",
       "  'from IPython.utils.contexts import NoOpContext\\n',\n",
       "  'from IPython.utils.decorators import undoc\\n',\n",
       "  'from IPython.utils.io import ask_yes_no\\n',\n",
       "  'from IPython.utils.ipstruct import Struct\\n',\n",
       "  'from IPython.paths import get_ipython_dir\\n',\n",
       "  'from IPython.utils.path import get_home_dir, get_py_filename, unquote_filename, ensure_dir_exists\\n',\n",
       "  'from IPython.utils.process import system, getoutput\\n',\n",
       "  'from IPython.utils.py3compat import (builtin_mod, unicode_type, string_types,\\n',\n",
       "  '                                     with_metaclass, iteritems)\\n',\n",
       "  'from IPython.utils.strdispatch import StrDispatch\\n',\n",
       "  'from IPython.utils.syspathcontext import prepended_to_syspath\\n',\n",
       "  'from IPython.utils.text import (format_screen, LSString, SList,\\n',\n",
       "  '                                DollarFormatter)\\n',\n",
       "  'from traitlets import (Integer, Bool, CBool, CaselessStrEnum, Enum,\\n',\n",
       "  '                                     List, Dict, Unicode, Instance, Type)\\n',\n",
       "  'from IPython.utils.warn import warn, error\\n',\n",
       "  'import IPython.core.hooks\\n',\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '# Globals\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '# compiled regexps for autoindent management\\n',\n",
       "  \"dedent_re = re.compile(r'^\\\\s+raise|^\\\\s+return|^\\\\s+pass')\\n\",\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '# Utilities\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '@undoc\\n',\n",
       "  'def softspace(file, newvalue):\\n',\n",
       "  '    \"\"\"Copied from code.py, to remove the dependency\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    oldvalue = 0\\n',\n",
       "  '    try:\\n',\n",
       "  '        oldvalue = file.softspace\\n',\n",
       "  '    except AttributeError:\\n',\n",
       "  '        pass\\n',\n",
       "  '    try:\\n',\n",
       "  '        file.softspace = newvalue\\n',\n",
       "  '    except (AttributeError, TypeError):\\n',\n",
       "  '        # \"attribute-less object\" or \"read-only attributes\"\\n',\n",
       "  '        pass\\n',\n",
       "  '    return oldvalue\\n',\n",
       "  '\\n',\n",
       "  '@undoc\\n',\n",
       "  'def no_op(*a, **kw): pass\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class SpaceInInput(Exception): pass\\n',\n",
       "  '\\n',\n",
       "  '@undoc\\n',\n",
       "  'class Bunch: pass\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'def get_default_colors():\\n',\n",
       "  \"    if sys.platform=='darwin':\\n\",\n",
       "  '        return \"LightBG\"\\n',\n",
       "  \"    elif os.name=='nt':\\n\",\n",
       "  \"        return 'Linux'\\n\",\n",
       "  '    else:\\n',\n",
       "  \"        return 'Linux'\\n\",\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class SeparateUnicode(Unicode):\\n',\n",
       "  '    r\"\"\"A Unicode subclass to validate separate_in, separate_out, etc.\\n',\n",
       "  '\\n',\n",
       "  \"    This is a Unicode based trait that converts '0'->'' and ``'\\\\\\\\n'->'\\\\n'``.\\n\",\n",
       "  '    \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    def validate(self, obj, value):\\n',\n",
       "  \"        if value == '0': value = ''\\n\",\n",
       "  \"        value = value.replace('\\\\\\\\n','\\\\n')\\n\",\n",
       "  '        return super(SeparateUnicode, self).validate(obj, value)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '@undoc\\n',\n",
       "  'class DummyMod(object):\\n',\n",
       "  '    \"\"\"A dummy module used for IPython\\'s interactive module when\\n',\n",
       "  '    a namespace must be assigned to the module\\'s __dict__.\"\"\"\\n',\n",
       "  '    pass\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class ExecutionResult(object):\\n',\n",
       "  '    \"\"\"The result of a call to :meth:`InteractiveShell.run_cell`\\n',\n",
       "  '\\n',\n",
       "  '    Stores information about what took place.\\n',\n",
       "  '    \"\"\"\\n',\n",
       "  '    execution_count = None\\n',\n",
       "  '    error_before_exec = None\\n',\n",
       "  '    error_in_exec = None\\n',\n",
       "  '    result = None\\n',\n",
       "  '\\n',\n",
       "  '    @property\\n',\n",
       "  '    def success(self):\\n',\n",
       "  '        return (self.error_before_exec is None) and (self.error_in_exec is None)\\n',\n",
       "  '\\n',\n",
       "  '    def raise_error(self):\\n',\n",
       "  '        \"\"\"Reraises error if `success` is `False`, otherwise does nothing\"\"\"\\n',\n",
       "  '        if self.error_before_exec is not None:\\n',\n",
       "  '            raise self.error_before_exec\\n',\n",
       "  '        if self.error_in_exec is not None:\\n',\n",
       "  '            raise self.error_in_exec\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class InteractiveShell(SingletonConfigurable):\\n',\n",
       "  '    \"\"\"An enhanced, interactive shell for Python.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    _instance = None\\n',\n",
       "  '    \\n',\n",
       "  '    ast_transformers = List([], config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        A list of ast.NodeTransformer subclass instances, which will be applied\\n',\n",
       "  '        to user input before code is run.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    autocall = Enum((0,1,2), default_value=0, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        Make IPython automatically call any callable object even if you didn't\\n\",\n",
       "  \"        type explicit parentheses. For example, 'str 43' becomes 'str(43)'\\n\",\n",
       "  \"        automatically. The value can be '0' to disable the feature, '1' for\\n\",\n",
       "  \"        'smart' autocall, where it is not applied if there are no more\\n\",\n",
       "  \"        arguments on the line, and '2' for 'full' autocall, where all callable\\n\",\n",
       "  '        objects are automatically called (even if no arguments are present).\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    # TODO: remove all autoindent logic and put into frontends.\\n',\n",
       "  \"    # We can't do this yet because even runlines uses the autoindent.\\n\",\n",
       "  '    autoindent = CBool(True, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Autoindent IPython code entered interactively.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    automagic = CBool(True, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Enable magic commands to be called without the leading %.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    \\n',\n",
       "  '    banner1 = Unicode(default_banner, config=True,\\n',\n",
       "  '        help=\"\"\"The part of the banner to be printed before the profile\"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  \"    banner2 = Unicode('', config=True,\\n\",\n",
       "  '        help=\"\"\"The part of the banner to be printed after the profile\"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    cache_size = Integer(1000, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Set the size of the output cache.  The default is 1000, you can\\n',\n",
       "  '        change it permanently in your config file.  Setting it to 0 completely\\n',\n",
       "  '        disables the caching system, and the minimum value accepted is 20 (if\\n',\n",
       "  '        you provide a value less than 20, it is reset to 0 and a warning is\\n',\n",
       "  \"        issued).  This limit is defined because otherwise you'll spend more\\n\",\n",
       "  '        time re-flushing a too small cache than working\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    color_info = CBool(True, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Use colors for displaying information about objects. Because this\\n',\n",
       "  \"        information is passed through a pager (like 'less'), and some pagers\\n\",\n",
       "  '        get confused with color codes, this capability can be turned off.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  \"    colors = CaselessStrEnum(('NoColor','LightBG','Linux'),\\n\",\n",
       "  '                             default_value=get_default_colors(), config=True,\\n',\n",
       "  '        help=\"Set the color scheme (NoColor, Linux, or LightBG).\"\\n',\n",
       "  '    )\\n',\n",
       "  '    colors_force = CBool(False, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Force use of ANSI color codes, regardless of OS and readline\\n',\n",
       "  '        availability.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        # FIXME: This is essentially a hack to allow ZMQShell to show colors\\n',\n",
       "  '        # without readline on Win32. When the ZMQ formatting system is\\n',\n",
       "  '        # refactored, this should be removed.\\n',\n",
       "  '    )\\n',\n",
       "  '    debug = CBool(False, config=True)\\n',\n",
       "  '    deep_reload = CBool(False, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        **Deprecated**\\n',\n",
       "  '\\n',\n",
       "  '        Will be removed in IPython 6.0\\n',\n",
       "  '\\n',\n",
       "  '        Enable deep (recursive) reloading by default. IPython can use the\\n',\n",
       "  '        deep_reload module which reloads changes in modules recursively (it\\n',\n",
       "  \"        replaces the reload() function, so you don't need to change anything to\\n\",\n",
       "  '        use it). `deep_reload` forces a full reload of modules whose code may\\n',\n",
       "  '        have changed, which the default reload() function does not.  When\\n',\n",
       "  '        deep_reload is off, IPython will use the normal reload(), but\\n',\n",
       "  '        deep_reload will still be available as dreload().\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    disable_failing_post_execute = CBool(False, config=True,\\n',\n",
       "  '        help=\"Don\\'t call post-execute functions that have failed in the past.\"\\n',\n",
       "  '    )\\n',\n",
       "  '    display_formatter = Instance(DisplayFormatter, allow_none=True)\\n',\n",
       "  '    displayhook_class = Type(DisplayHook)\\n',\n",
       "  '    display_pub_class = Type(DisplayPublisher)\\n',\n",
       "  '    data_pub_class = None\\n',\n",
       "  '\\n',\n",
       "  '    exit_now = CBool(False)\\n',\n",
       "  '    exiter = Instance(ExitAutocall)\\n',\n",
       "  '    def _exiter_default(self):\\n',\n",
       "  '        return ExitAutocall(self)\\n',\n",
       "  '    # Monotonically increasing execution counter\\n',\n",
       "  '    execution_count = Integer(1)\\n',\n",
       "  '    filename = Unicode(\"<ipython console>\")\\n',\n",
       "  \"    ipython_dir= Unicode('', config=True) # Set to get_ipython_dir() in __init__\\n\",\n",
       "  '\\n',\n",
       "  '    # Input splitter, to transform input line by line and detect when a block\\n',\n",
       "  '    # is ready to be executed.\\n',\n",
       "  \"    input_splitter = Instance('IPython.core.inputsplitter.IPythonInputSplitter',\\n\",\n",
       "  \"                              (), {'line_input_checker': True})\\n\",\n",
       "  '    \\n',\n",
       "  '    # This InputSplitter instance is used to transform completed cells before\\n',\n",
       "  '    # running them. It allows cell magics to contain blank lines.\\n',\n",
       "  \"    input_transformer_manager = Instance('IPython.core.inputsplitter.IPythonInputSplitter',\\n\",\n",
       "  \"                                         (), {'line_input_checker': False})\\n\",\n",
       "  '    \\n',\n",
       "  '    logstart = CBool(False, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Start logging to the default log file in overwrite mode.\\n',\n",
       "  '        Use `logappend` to specify a log file to **append** logs to.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  \"    logfile = Unicode('', config=True, help=\\n\",\n",
       "  '        \"\"\"\\n',\n",
       "  '        The name of the logfile to use.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  \"    logappend = Unicode('', config=True, help=\\n\",\n",
       "  '        \"\"\"\\n',\n",
       "  '        Start logging to the given file in append mode.\\n',\n",
       "  '        Use `logfile` to specify a log file to **overwrite** logs to.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    object_info_string_level = Enum((0,1,2), default_value=0,\\n',\n",
       "  '                                    config=True)\\n',\n",
       "  '    pdb = CBool(False, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        Automatically call the pdb debugger after every exception.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  \"    multiline_history = CBool(sys.platform != 'win32', config=True,\\n\",\n",
       "  '        help=\"Save multi-line entries as one entry in readline history\"\\n',\n",
       "  '    )\\n',\n",
       "  '    display_page = Bool(False, config=True,\\n',\n",
       "  '        help=\"\"\"If True, anything that would be passed to the pager\\n',\n",
       "  '        will be displayed as regular output instead.\"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    # deprecated prompt traits:\\n',\n",
       "  '    \\n',\n",
       "  \"    prompt_in1 = Unicode('In [\\\\\\\\#]: ', config=True,\\n\",\n",
       "  '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.in_template\")\\n',\n",
       "  \"    prompt_in2 = Unicode('   .\\\\\\\\D.: ', config=True,\\n\",\n",
       "  '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.in2_template\")\\n',\n",
       "  \"    prompt_out = Unicode('Out[\\\\\\\\#]: ', config=True,\\n\",\n",
       "  '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.out_template\")\\n',\n",
       "  '    prompts_pad_left = CBool(True, config=True,\\n',\n",
       "  '        help=\"Deprecated, will be removed in IPython 5.0, use PromptManager.justify\")\\n',\n",
       "  '    \\n',\n",
       "  '    def _prompt_trait_changed(self, name, old, new):\\n',\n",
       "  '        table = {\\n',\n",
       "  \"            'prompt_in1' : 'in_template',\\n\",\n",
       "  \"            'prompt_in2' : 'in2_template',\\n\",\n",
       "  \"            'prompt_out' : 'out_template',\\n\",\n",
       "  \"            'prompts_pad_left' : 'justify',\\n\",\n",
       "  '        }\\n',\n",
       "  '        warn(\"InteractiveShell.{name} is deprecated, use PromptManager.{newname}\".format(\\n',\n",
       "  '                name=name, newname=table[name])\\n',\n",
       "  '        )\\n',\n",
       "  '        # protect against weird cases where self.config may not exist:\\n',\n",
       "  '        if self.config is not None:\\n',\n",
       "  '            # propagate to corresponding PromptManager trait\\n',\n",
       "  '            setattr(self.config.PromptManager, table[name], new)\\n',\n",
       "  '    \\n',\n",
       "  '    _prompt_in1_changed = _prompt_trait_changed\\n',\n",
       "  '    _prompt_in2_changed = _prompt_trait_changed\\n',\n",
       "  '    _prompt_out_changed = _prompt_trait_changed\\n',\n",
       "  '    _prompt_pad_left_changed = _prompt_trait_changed\\n',\n",
       "  '    \\n',\n",
       "  '    show_rewritten_input = CBool(True, config=True,\\n',\n",
       "  '        help=\"Show rewritten input, e.g. for autocall.\"\\n',\n",
       "  '    )\\n',\n",
       "  '    \\n',\n",
       "  '    quiet = CBool(False, config=True)\\n',\n",
       "  '\\n',\n",
       "  '    history_length = Integer(10000, config=True)\\n',\n",
       "  '\\n',\n",
       "  '    history_load_length = Integer(1000, config=True, help=\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        The number of saved history entries to be loaded\\n',\n",
       "  '        into the readline buffer at startup.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    # The readline stuff will eventually be moved to the terminal subclass\\n',\n",
       "  \"    # but for now, we can't do that as readline is welded in everywhere.\\n\",\n",
       "  '    readline_use = CBool(True, config=True)\\n',\n",
       "  \"    readline_remove_delims = Unicode('-/~', config=True)\\n\",\n",
       "  '    readline_delims = Unicode() # set by init_readline()\\n',\n",
       "  \"    # don't use \\\\M- bindings by default, because they\\n\",\n",
       "  '    # conflict with 8-bit encodings. See gh-58,gh-88\\n',\n",
       "  '    readline_parse_and_bind = List([\\n',\n",
       "  \"            'tab: complete',\\n\",\n",
       "  '            \\'\"\\\\C-l\": clear-screen\\',\\n',\n",
       "  \"            'set show-all-if-ambiguous on',\\n\",\n",
       "  '            \\'\"\\\\C-o\": tab-insert\\',\\n',\n",
       "  '            \\'\"\\\\C-r\": reverse-search-history\\',\\n',\n",
       "  '            \\'\"\\\\C-s\": forward-search-history\\',\\n',\n",
       "  '            \\'\"\\\\C-p\": history-search-backward\\',\\n',\n",
       "  '            \\'\"\\\\C-n\": history-search-forward\\',\\n',\n",
       "  '            \\'\"\\\\e[A\": history-search-backward\\',\\n',\n",
       "  '            \\'\"\\\\e[B\": history-search-forward\\',\\n',\n",
       "  '            \\'\"\\\\C-k\": kill-line\\',\\n',\n",
       "  '            \\'\"\\\\C-u\": unix-line-discard\\',\\n',\n",
       "  '        ], config=True)\\n',\n",
       "  '    \\n',\n",
       "  '    _custom_readline_config = False\\n',\n",
       "  '    \\n',\n",
       "  '    def _readline_parse_and_bind_changed(self, name, old, new):\\n',\n",
       "  '        # notice that readline config is customized\\n',\n",
       "  '        # indicates that it should have higher priority than inputrc\\n',\n",
       "  '        self._custom_readline_config = True\\n',\n",
       "  '    \\n',\n",
       "  \"    ast_node_interactivity = Enum(['all', 'last', 'last_expr', 'none'],\\n\",\n",
       "  \"                                  default_value='last_expr', config=True, \\n\",\n",
       "  '                                  help=\"\"\"\\n',\n",
       "  \"        'all', 'last', 'last_expr' or 'none', specifying which nodes should be\\n\",\n",
       "  '        run interactively (displaying output from expressions).\"\"\")\\n',\n",
       "  '\\n',\n",
       "  '    # TODO: this part of prompt management should be moved to the frontends.\\n',\n",
       "  \"    # Use custom TraitTypes that convert '0'->'' and '\\\\\\\\n'->'\\\\n'\\n\",\n",
       "  \"    separate_in = SeparateUnicode('\\\\n', config=True)\\n\",\n",
       "  \"    separate_out = SeparateUnicode('', config=True)\\n\",\n",
       "  \"    separate_out2 = SeparateUnicode('', config=True)\\n\",\n",
       "  '    wildcards_case_sensitive = CBool(True, config=True)\\n',\n",
       "  \"    xmode = CaselessStrEnum(('Context','Plain', 'Verbose'),\\n\",\n",
       "  \"                            default_value='Context', config=True)\\n\",\n",
       "  '\\n',\n",
       "  '    # Subcomponents of InteractiveShell\\n',\n",
       "  \"    alias_manager = Instance('IPython.core.alias.AliasManager', allow_none=True)\\n\",\n",
       "  \"    prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True)\\n\",\n",
       "  \"    builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap', allow_none=True)\\n\",\n",
       "  \"    display_trap = Instance('IPython.core.display_trap.DisplayTrap', allow_none=True)\\n\",\n",
       "  \"    extension_manager = Instance('IPython.core.extensions.ExtensionManager', allow_none=True)\\n\",\n",
       "  \"    payload_manager = Instance('IPython.core.payload.PayloadManager', allow_none=True)\\n\",\n",
       "  \"    history_manager = Instance('IPython.core.history.HistoryAccessorBase', allow_none=True)\\n\",\n",
       "  \"    magics_manager = Instance('IPython.core.magic.MagicsManager', allow_none=True)\\n\",\n",
       "  '\\n',\n",
       "  \"    profile_dir = Instance('IPython.core.application.ProfileDir', allow_none=True)\\n\",\n",
       "  '    @property\\n',\n",
       "  '    def profile(self):\\n',\n",
       "  '        if self.profile_dir is not None:\\n',\n",
       "  '            name = os.path.basename(self.profile_dir.location)\\n',\n",
       "  \"            return name.replace('profile_','')\\n\",\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '    # Private interface\\n',\n",
       "  '    _post_execute = Dict()\\n',\n",
       "  '\\n',\n",
       "  '    # Tracks any GUI loop loaded for pylab\\n',\n",
       "  '    pylab_gui_select = None\\n',\n",
       "  '\\n',\n",
       "  '    def __init__(self, ipython_dir=None, profile_dir=None,\\n',\n",
       "  '                 user_module=None, user_ns=None,\\n',\n",
       "  '                 custom_exceptions=((), None), **kwargs):\\n',\n",
       "  '\\n',\n",
       "  '        # This is where traits with a config_key argument are updated\\n',\n",
       "  '        # from the values on config.\\n',\n",
       "  '        super(InteractiveShell, self).__init__(**kwargs)\\n',\n",
       "  '        self.configurables = [self]\\n',\n",
       "  '\\n',\n",
       "  '        # These are relatively independent and stateless\\n',\n",
       "  '        self.init_ipython_dir(ipython_dir)\\n',\n",
       "  '        self.init_profile_dir(profile_dir)\\n',\n",
       "  '        self.init_instance_attrs()\\n',\n",
       "  '        self.init_environment()\\n',\n",
       "  '        \\n',\n",
       "  \"        # Check if we're in a virtualenv, and set up sys.path.\\n\",\n",
       "  '        self.init_virtualenv()\\n',\n",
       "  '\\n',\n",
       "  '        # Create namespaces (user_ns, user_global_ns, etc.)\\n',\n",
       "  '        self.init_create_namespaces(user_module, user_ns)\\n',\n",
       "  '        # This has to be done after init_create_namespaces because it uses\\n',\n",
       "  '        # something in self.user_ns, but before init_sys_modules, which\\n',\n",
       "  '        # is the first thing to modify sys.\\n',\n",
       "  '        # TODO: When we override sys.stdout and sys.stderr before this class\\n',\n",
       "  '        # is created, we are saving the overridden ones here. Not sure if this\\n',\n",
       "  '        # is what we want to do.\\n',\n",
       "  '        self.save_sys_module_state()\\n',\n",
       "  '        self.init_sys_modules()\\n',\n",
       "  '\\n',\n",
       "  \"        # While we're trying to have each part of the code directly access what\\n\",\n",
       "  '        # it needs without keeping redundant references to objects, we have too\\n',\n",
       "  '        # much legacy code that expects ip.db to exist.\\n',\n",
       "  \"        self.db = PickleShareDB(os.path.join(self.profile_dir.location, 'db'))\\n\",\n",
       "  '\\n',\n",
       "  '        self.init_history()\\n',\n",
       "  '        self.init_encoding()\\n',\n",
       "  '        self.init_prefilter()\\n',\n",
       "  '\\n',\n",
       "  '        self.init_syntax_highlighting()\\n',\n",
       "  '        self.init_hooks()\\n',\n",
       "  '        self.init_events()\\n',\n",
       "  '        self.init_pushd_popd_magic()\\n',\n",
       "  '        # self.init_traceback_handlers use to be here, but we moved it below\\n',\n",
       "  '        # because it and init_io have to come after init_readline.\\n',\n",
       "  '        self.init_user_ns()\\n',\n",
       "  '        self.init_logger()\\n',\n",
       "  '        self.init_builtins()\\n',\n",
       "  '\\n',\n",
       "  '        # The following was in post_config_initialization\\n',\n",
       "  '        self.init_inspector()\\n',\n",
       "  '        # init_readline() must come before init_io(), because init_io uses\\n',\n",
       "  '        # readline related things.\\n',\n",
       "  '        self.init_readline()\\n',\n",
       "  '        # We save this here in case user code replaces raw_input, but it needs\\n',\n",
       "  \"        # to be after init_readline(), because PyPy's readline works by replacing\\n\",\n",
       "  '        # raw_input.\\n',\n",
       "  '        if py3compat.PY3:\\n',\n",
       "  '            self.raw_input_original = input\\n',\n",
       "  '        else:\\n',\n",
       "  '            self.raw_input_original = raw_input\\n',\n",
       "  '        # init_completer must come after init_readline, because it needs to\\n',\n",
       "  '        # know whether readline is present or not system-wide to configure the\\n',\n",
       "  '        # completers, since the completion machinery can now operate\\n',\n",
       "  '        # independently of readline (e.g. over the network)\\n',\n",
       "  '        self.init_completer()\\n',\n",
       "  '        # TODO: init_io() needs to happen before init_traceback handlers\\n',\n",
       "  '        # because the traceback handlers hardcode the stdout/stderr streams.\\n',\n",
       "  '        # This logic in in debugger.Pdb and should eventually be changed.\\n',\n",
       "  '        self.init_io()\\n',\n",
       "  '        self.init_traceback_handlers(custom_exceptions)\\n',\n",
       "  '        self.init_prompts()\\n',\n",
       "  '        self.init_display_formatter()\\n',\n",
       "  '        self.init_display_pub()\\n',\n",
       "  '        self.init_data_pub()\\n',\n",
       "  '        self.init_displayhook()\\n',\n",
       "  '        self.init_magics()\\n',\n",
       "  '        self.init_alias()\\n',\n",
       "  '        self.init_logstart()\\n',\n",
       "  '        self.init_pdb()\\n',\n",
       "  '        self.init_extension_manager()\\n',\n",
       "  '        self.init_payload()\\n',\n",
       "  '        self.init_deprecation_warnings()\\n',\n",
       "  '        self.hooks.late_startup_hook()\\n',\n",
       "  \"        self.events.trigger('shell_initialized', self)\\n\",\n",
       "  '        atexit.register(self.atexit_operations)\\n',\n",
       "  '\\n',\n",
       "  '    def get_ipython(self):\\n',\n",
       "  '        \"\"\"Return the currently running IPython instance.\"\"\"\\n',\n",
       "  '        return self\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Trait changed handlers\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def _ipython_dir_changed(self, name, new):\\n',\n",
       "  '        ensure_dir_exists(new)\\n',\n",
       "  '\\n',\n",
       "  '    def set_autoindent(self,value=None):\\n',\n",
       "  '        \"\"\"Set the autoindent flag, checking for readline support.\\n',\n",
       "  '\\n',\n",
       "  '        If called with no arguments, it acts as a toggle.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        if value != 0 and not self.has_readline:\\n',\n",
       "  \"            if os.name == 'posix':\\n\",\n",
       "  '                warn(\"The auto-indent feature requires the readline library\")\\n',\n",
       "  '            self.autoindent = 0\\n',\n",
       "  '            return\\n',\n",
       "  '        if value is None:\\n',\n",
       "  '            self.autoindent = not self.autoindent\\n',\n",
       "  '        else:\\n',\n",
       "  '            self.autoindent = value\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # init_* methods called by __init__\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def init_ipython_dir(self, ipython_dir):\\n',\n",
       "  '        if ipython_dir is not None:\\n',\n",
       "  '            self.ipython_dir = ipython_dir\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        self.ipython_dir = get_ipython_dir()\\n',\n",
       "  '\\n',\n",
       "  '    def init_profile_dir(self, profile_dir):\\n',\n",
       "  '        if profile_dir is not None:\\n',\n",
       "  '            self.profile_dir = profile_dir\\n',\n",
       "  '            return\\n',\n",
       "  '        self.profile_dir =\\\\\\n',\n",
       "  \"            ProfileDir.create_profile_dir_by_name(self.ipython_dir, 'default')\\n\",\n",
       "  '\\n',\n",
       "  '    def init_instance_attrs(self):\\n',\n",
       "  '        self.more = False\\n',\n",
       "  '\\n',\n",
       "  '        # command compiler\\n',\n",
       "  '        self.compile = CachingCompiler()\\n',\n",
       "  '\\n',\n",
       "  '        # Make an empty namespace, which extension writers can rely on both\\n',\n",
       "  '        # existing and NEVER being used by ipython itself.  This gives them a\\n',\n",
       "  '        # convenient location for storing additional information and state\\n',\n",
       "  '        # their extensions may require, without fear of collisions with other\\n',\n",
       "  '        # ipython names that may develop later.\\n',\n",
       "  '        self.meta = Struct()\\n',\n",
       "  '\\n',\n",
       "  '        # Temporary files used for various purposes.  Deleted at exit.\\n',\n",
       "  '        self.tempfiles = []\\n',\n",
       "  '        self.tempdirs = []\\n',\n",
       "  '\\n',\n",
       "  '        # Keep track of readline usage (later set by init_readline)\\n',\n",
       "  '        self.has_readline = False\\n',\n",
       "  '\\n',\n",
       "  '        # keep track of where we started running (mainly for crash post-mortem)\\n',\n",
       "  '        # This is not being used anywhere currently.\\n',\n",
       "  '        self.starting_dir = py3compat.getcwd()\\n',\n",
       "  '\\n',\n",
       "  '        # Indentation management\\n',\n",
       "  '        self.indent_current_nsp = 0\\n',\n",
       "  '\\n',\n",
       "  '        # Dict to track post-execution functions that have been registered\\n',\n",
       "  '        self._post_execute = {}\\n',\n",
       "  '\\n',\n",
       "  '    def init_environment(self):\\n',\n",
       "  '        \"\"\"Any changes we need to make to the user\\'s environment.\"\"\"\\n',\n",
       "  '        pass\\n',\n",
       "  '\\n',\n",
       "  '    def init_encoding(self):\\n',\n",
       "  '        # Get system encoding at startup time.  Certain terminals (like Emacs\\n',\n",
       "  '        # under Win32 have it set to None, and we need to have a known valid\\n',\n",
       "  '        # encoding to use in the raw_input() method\\n',\n",
       "  '        try:\\n',\n",
       "  \"            self.stdin_encoding = sys.stdin.encoding or 'ascii'\\n\",\n",
       "  '        except AttributeError:\\n',\n",
       "  \"            self.stdin_encoding = 'ascii'\\n\",\n",
       "  '\\n',\n",
       "  '    def init_syntax_highlighting(self):\\n',\n",
       "  '        # Python source parser/formatter for syntax highlighting\\n',\n",
       "  '        pyformat = PyColorize.Parser().format\\n',\n",
       "  \"        self.pycolorize = lambda src: pyformat(src,'str',self.colors)\\n\",\n",
       "  '\\n',\n",
       "  '    def init_pushd_popd_magic(self):\\n',\n",
       "  '        # for pushd/popd management\\n',\n",
       "  '        self.home_dir = get_home_dir()\\n',\n",
       "  '\\n',\n",
       "  '        self.dir_stack = []\\n',\n",
       "  '\\n',\n",
       "  '    def init_logger(self):\\n',\n",
       "  \"        self.logger = Logger(self.home_dir, logfname='ipython_log.py',\\n\",\n",
       "  \"                             logmode='rotate')\\n\",\n",
       "  '\\n',\n",
       "  '    def init_logstart(self):\\n',\n",
       "  '        \"\"\"Initialize logging in case it was requested at the command line.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if self.logappend:\\n',\n",
       "  \"            self.magic('logstart %s append' % self.logappend)\\n\",\n",
       "  '        elif self.logfile:\\n',\n",
       "  \"            self.magic('logstart %s' % self.logfile)\\n\",\n",
       "  '        elif self.logstart:\\n',\n",
       "  \"            self.magic('logstart')\\n\",\n",
       "  '\\n',\n",
       "  '    def init_deprecation_warnings(self):\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        register default filter for deprecation warning.\\n',\n",
       "  '\\n',\n",
       "  '        This will allow deprecation warning of function used interactively to show\\n',\n",
       "  '        warning to users, and still hide deprecation warning from libraries import.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        warnings.filterwarnings(\"default\", category=DeprecationWarning, module=self.user_ns.get(\"__name__\"))\\n',\n",
       "  '\\n',\n",
       "  '    def init_builtins(self):\\n',\n",
       "  '        # A single, static flag that we set to True.  Its presence indicates\\n',\n",
       "  '        # that an IPython shell has been created, and we make no attempts at\\n',\n",
       "  '        # removing on exit or representing the existence of more than one\\n',\n",
       "  '        # IPython at a time.\\n',\n",
       "  \"        builtin_mod.__dict__['__IPYTHON__'] = True\\n\",\n",
       "  '\\n',\n",
       "  \"        # In 0.11 we introduced '__IPYTHON__active' as an integer we'd try to\\n\",\n",
       "  \"        # manage on enter/exit, but with all our shells it's virtually\\n\",\n",
       "  \"        # impossible to get all the cases right.  We're leaving the name in for\\n\",\n",
       "  '        # those who adapted their codes to check for this flag, but will\\n',\n",
       "  '        # eventually remove it after a few more releases.\\n',\n",
       "  \"        builtin_mod.__dict__['__IPYTHON__active'] = \\\\\\n\",\n",
       "  \"                                          'Deprecated, check for __IPYTHON__'\\n\",\n",
       "  '\\n',\n",
       "  '        self.builtin_trap = BuiltinTrap(shell=self)\\n',\n",
       "  '\\n',\n",
       "  '    def init_inspector(self):\\n',\n",
       "  '        # Object inspector\\n',\n",
       "  '        self.inspector = oinspect.Inspector(oinspect.InspectColors,\\n',\n",
       "  '                                            PyColorize.ANSICodeColors,\\n',\n",
       "  \"                                            'NoColor',\\n\",\n",
       "  '                                            self.object_info_string_level)\\n',\n",
       "  '\\n',\n",
       "  '    def init_io(self):\\n',\n",
       "  '        # This will just use sys.stdout and sys.stderr. If you want to\\n',\n",
       "  '        # override sys.stdout and sys.stderr themselves, you need to do that\\n',\n",
       "  '        # *before* instantiating this class, because io holds onto\\n',\n",
       "  '        # references to the underlying streams.\\n',\n",
       "  \"        if (sys.platform == 'win32' or sys.platform == 'cli') and self.has_readline:\\n\",\n",
       "  '            io.stdout = io.stderr = io.IOStream(self.readline._outputfile)\\n',\n",
       "  '        else:\\n',\n",
       "  '            io.stdout = io.IOStream(sys.stdout)\\n',\n",
       "  '            io.stderr = io.IOStream(sys.stderr)\\n',\n",
       "  '\\n',\n",
       "  '    def init_prompts(self):\\n',\n",
       "  '        self.prompt_manager = PromptManager(shell=self, parent=self)\\n',\n",
       "  '        self.configurables.append(self.prompt_manager)\\n',\n",
       "  '        # Set system prompts, so that scripts can decide if they are running\\n',\n",
       "  '        # interactively.\\n',\n",
       "  \"        sys.ps1 = 'In : '\\n\",\n",
       "  \"        sys.ps2 = '...: '\\n\",\n",
       "  \"        sys.ps3 = 'Out: '\\n\",\n",
       "  '\\n',\n",
       "  '    def init_display_formatter(self):\\n',\n",
       "  '        self.display_formatter = DisplayFormatter(parent=self)\\n',\n",
       "  '        self.configurables.append(self.display_formatter)\\n',\n",
       "  '\\n',\n",
       "  '    def init_display_pub(self):\\n',\n",
       "  '        self.display_pub = self.display_pub_class(parent=self)\\n',\n",
       "  '        self.configurables.append(self.display_pub)\\n',\n",
       "  '\\n',\n",
       "  '    def init_data_pub(self):\\n',\n",
       "  '        if not self.data_pub_class:\\n',\n",
       "  '            self.data_pub = None\\n',\n",
       "  '            return\\n',\n",
       "  '        self.data_pub = self.data_pub_class(parent=self)\\n',\n",
       "  '        self.configurables.append(self.data_pub)\\n',\n",
       "  '\\n',\n",
       "  '    def init_displayhook(self):\\n',\n",
       "  '        # Initialize displayhook, set in/out prompts and printing system\\n',\n",
       "  '        self.displayhook = self.displayhook_class(\\n',\n",
       "  '            parent=self,\\n',\n",
       "  '            shell=self,\\n',\n",
       "  '            cache_size=self.cache_size,\\n',\n",
       "  '        )\\n',\n",
       "  '        self.configurables.append(self.displayhook)\\n',\n",
       "  '        # This is a context manager that installs/revmoes the displayhook at\\n',\n",
       "  '        # the appropriate time.\\n',\n",
       "  '        self.display_trap = DisplayTrap(hook=self.displayhook)\\n',\n",
       "  '\\n',\n",
       "  '    def init_virtualenv(self):\\n',\n",
       "  '        \"\"\"Add a virtualenv to sys.path so the user can import modules from it.\\n',\n",
       "  \"        This isn't perfect: it doesn't use the Python interpreter with which the\\n\",\n",
       "  '        virtualenv was built, and it ignores the --no-site-packages option. A\\n',\n",
       "  '        warning will appear suggesting the user installs IPython in the\\n',\n",
       "  '        virtualenv, but for many cases, it probably works well enough.\\n',\n",
       "  '        \\n',\n",
       "  '        Adapted from code snippets online.\\n',\n",
       "  '        \\n',\n",
       "  '        http://blog.ufsoft.org/2009/1/29/ipython-and-virtualenv\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        if 'VIRTUAL_ENV' not in os.environ:\\n\",\n",
       "  '            # Not in a virtualenv\\n',\n",
       "  '            return\\n',\n",
       "  '        \\n',\n",
       "  '        # venv detection:\\n',\n",
       "  \"        # stdlib venv may symlink sys.executable, so we can't use realpath.\\n\",\n",
       "  \"        # but others can symlink *to* the venv Python, so we can't just use sys.executable.\\n\",\n",
       "  '        # So we just check every item in the symlink tree (generally <= 3)\\n',\n",
       "  '        p = os.path.normcase(sys.executable)\\n',\n",
       "  '        paths = [p]\\n',\n",
       "  '        while os.path.islink(p):\\n',\n",
       "  '            p = os.path.normcase(os.path.join(os.path.dirname(p), os.readlink(p)))\\n',\n",
       "  '            paths.append(p)\\n',\n",
       "  \"        p_venv = os.path.normcase(os.environ['VIRTUAL_ENV'])\\n\",\n",
       "  '        if any(p.startswith(p_venv) for p in paths):\\n',\n",
       "  \"            # Running properly in the virtualenv, don't need to do anything\\n\",\n",
       "  '            return\\n',\n",
       "  '        \\n',\n",
       "  '        warn(\"Attempting to work in a virtualenv. If you encounter problems, please \"\\n',\n",
       "  '             \"install IPython inside the virtualenv.\")\\n',\n",
       "  '        if sys.platform == \"win32\":\\n',\n",
       "  \"            virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'Lib', 'site-packages') \\n\",\n",
       "  '        else:\\n',\n",
       "  \"            virtual_env = os.path.join(os.environ['VIRTUAL_ENV'], 'lib',\\n\",\n",
       "  \"                       'python%d.%d' % sys.version_info[:2], 'site-packages')\\n\",\n",
       "  '        \\n',\n",
       "  '        import site\\n',\n",
       "  '        sys.path.insert(0, virtual_env)\\n',\n",
       "  '        site.addsitedir(virtual_env)\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to injections into the sys module\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def save_sys_module_state(self):\\n',\n",
       "  '        \"\"\"Save the state of hooks in the sys module.\\n',\n",
       "  '\\n',\n",
       "  '        This has to be called after self.user_module is created.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        self._orig_sys_module_state = {'stdin': sys.stdin,\\n\",\n",
       "  \"                                       'stdout': sys.stdout,\\n\",\n",
       "  \"                                       'stderr': sys.stderr,\\n\",\n",
       "  \"                                       'excepthook': sys.excepthook}\\n\",\n",
       "  '        self._orig_sys_modules_main_name = self.user_module.__name__\\n',\n",
       "  '        self._orig_sys_modules_main_mod = sys.modules.get(self.user_module.__name__)\\n',\n",
       "  '\\n',\n",
       "  '    def restore_sys_module_state(self):\\n',\n",
       "  '        \"\"\"Restore the state of the sys module.\"\"\"\\n',\n",
       "  '        try:\\n',\n",
       "  '            for k, v in iteritems(self._orig_sys_module_state):\\n',\n",
       "  '                setattr(sys, k, v)\\n',\n",
       "  '        except AttributeError:\\n',\n",
       "  '            pass\\n',\n",
       "  '        # Reset what what done in self.init_sys_modules\\n',\n",
       "  '        if self._orig_sys_modules_main_mod is not None:\\n',\n",
       "  '            sys.modules[self._orig_sys_modules_main_name] = self._orig_sys_modules_main_mod\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to the banner\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    \\n',\n",
       "  '    @property\\n',\n",
       "  '    def banner(self):\\n',\n",
       "  '        banner = self.banner1\\n',\n",
       "  \"        if self.profile and self.profile != 'default':\\n\",\n",
       "  \"            banner += '\\\\nIPython profile: %s\\\\n' % self.profile\\n\",\n",
       "  '        if self.banner2:\\n',\n",
       "  \"            banner += '\\\\n' + self.banner2\\n\",\n",
       "  '        return banner\\n',\n",
       "  '\\n',\n",
       "  '    def show_banner(self, banner=None):\\n',\n",
       "  '        if banner is None:\\n',\n",
       "  '            banner = self.banner\\n',\n",
       "  '        self.write(banner)\\n',\n",
       "  '    \\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to hooks\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def init_hooks(self):\\n',\n",
       "  '        # hooks holds pointers used for user-side customizations\\n',\n",
       "  '        self.hooks = Struct()\\n',\n",
       "  '\\n',\n",
       "  '        self.strdispatchers = {}\\n',\n",
       "  '\\n',\n",
       "  '        # Set all default hooks, defined in the IPython.hooks module.\\n',\n",
       "  '        hooks = IPython.core.hooks\\n',\n",
       "  '        for hook_name in hooks.__all__:\\n',\n",
       "  '            # default hooks have priority 100, i.e. low; user hooks should have\\n',\n",
       "  '            # 0-100 priority\\n',\n",
       "  '            self.set_hook(hook_name,getattr(hooks,hook_name), 100, _warn_deprecated=False)\\n',\n",
       "  '        \\n',\n",
       "  '        if self.display_page:\\n',\n",
       "  \"            self.set_hook('show_in_pager', page.as_hook(page.display_page), 90)\\n\",\n",
       "  '    \\n',\n",
       "  '    def set_hook(self,name,hook, priority=50, str_key=None, re_key=None,\\n',\n",
       "  '                 _warn_deprecated=True):\\n',\n",
       "  '        \"\"\"set_hook(name,hook) -> sets an internal IPython hook.\\n',\n",
       "  '\\n',\n",
       "  '        IPython exposes some of its internal API as user-modifiable hooks.  By\\n',\n",
       "  \"        adding your function to one of these hooks, you can modify IPython's\\n\",\n",
       "  '        behavior to call at runtime your own routines.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        # At some point in the future, this should validate the hook before it\\n',\n",
       "  '        # accepts it.  Probably at least check that the hook takes the number\\n',\n",
       "  \"        # of args it's supposed to.\\n\",\n",
       "  '\\n',\n",
       "  '        f = types.MethodType(hook,self)\\n',\n",
       "  '\\n',\n",
       "  '        # check if the hook is for strdispatcher first\\n',\n",
       "  '        if str_key is not None:\\n',\n",
       "  '            sdp = self.strdispatchers.get(name, StrDispatch())\\n',\n",
       "  '            sdp.add_s(str_key, f, priority )\\n',\n",
       "  '            self.strdispatchers[name] = sdp\\n',\n",
       "  '            return\\n',\n",
       "  '        if re_key is not None:\\n',\n",
       "  '            sdp = self.strdispatchers.get(name, StrDispatch())\\n',\n",
       "  '            sdp.add_re(re.compile(re_key), f, priority )\\n',\n",
       "  '            self.strdispatchers[name] = sdp\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        dp = getattr(self.hooks, name, None)\\n',\n",
       "  '        if name not in IPython.core.hooks.__all__:\\n',\n",
       "  '            print(\"Warning! Hook \\'%s\\' is not one of %s\" % \\\\\\n',\n",
       "  '                  (name, IPython.core.hooks.__all__ ))\\n',\n",
       "  '\\n',\n",
       "  '        if _warn_deprecated and (name in IPython.core.hooks.deprecated):\\n',\n",
       "  '            alternative = IPython.core.hooks.deprecated[name]\\n',\n",
       "  '            warn(\"Hook {} is deprecated. Use {} instead.\".format(name, alternative))\\n',\n",
       "  '\\n',\n",
       "  '        if not dp:\\n',\n",
       "  '            dp = IPython.core.hooks.CommandChainDispatcher()\\n',\n",
       "  '\\n',\n",
       "  '        try:\\n',\n",
       "  '            dp.add(f,priority)\\n',\n",
       "  '        except AttributeError:\\n',\n",
       "  '            # it was not commandchain, plain old func - replace\\n',\n",
       "  '            dp = f\\n',\n",
       "  '\\n',\n",
       "  '        setattr(self.hooks,name, dp)\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to events\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def init_events(self):\\n',\n",
       "  '        self.events = EventManager(self, available_events)\\n',\n",
       "  '\\n',\n",
       "  '        self.events.register(\"pre_execute\", self._clear_warning_registry)\\n',\n",
       "  '\\n',\n",
       "  '    def register_post_execute(self, func):\\n',\n",
       "  '        \"\"\"DEPRECATED: Use ip.events.register(\\'post_run_cell\\', func)\\n',\n",
       "  '        \\n',\n",
       "  '        Register a function for calling after code execution.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        warn(\"ip.register_post_execute is deprecated, use \"\\n',\n",
       "  '             \"ip.events.register(\\'post_run_cell\\', func) instead.\")\\n',\n",
       "  \"        self.events.register('post_run_cell', func)\\n\",\n",
       "  '    \\n',\n",
       "  '    def _clear_warning_registry(self):\\n',\n",
       "  '        # clear the warning registry, so that different code blocks with\\n',\n",
       "  \"        # overlapping line number ranges don't cause spurious suppression of\\n\",\n",
       "  '        # warnings (see gh-6611 for details)\\n',\n",
       "  '        if \"__warningregistry__\" in self.user_global_ns:\\n',\n",
       "  '            del self.user_global_ns[\"__warningregistry__\"]\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to the \"main\" module\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def new_main_mod(self, filename, modname):\\n',\n",
       "  '        \"\"\"Return a new \\'main\\' module object for user code execution.\\n',\n",
       "  '        \\n',\n",
       "  '        ``filename`` should be the path of the script which will be run in the\\n',\n",
       "  '        module. Requests with the same filename will get the same module, with\\n',\n",
       "  '        its namespace cleared.\\n',\n",
       "  '        \\n',\n",
       "  \"        ``modname`` should be the module name - normally either '__main__' or\\n\",\n",
       "  '        the basename of the file without the extension.\\n',\n",
       "  '        \\n',\n",
       "  '        When scripts are executed via %run, we must keep a reference to their\\n',\n",
       "  \"        __main__ module around so that Python doesn't\\n\",\n",
       "  '        clear it, rendering references to module globals useless.\\n',\n",
       "  '\\n',\n",
       "  '        This method keeps said reference in a private dict, keyed by the\\n',\n",
       "  '        absolute path of the script. This way, for multiple executions of the\\n',\n",
       "  '        same script we only keep one copy of the namespace (the last one),\\n',\n",
       "  '        thus preventing memory leaks from old references while allowing the\\n',\n",
       "  '        objects from the last execution to be accessible.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        filename = os.path.abspath(filename)\\n',\n",
       "  '        try:\\n',\n",
       "  '            main_mod = self._main_mod_cache[filename]\\n',\n",
       "  '        except KeyError:\\n',\n",
       "  '            main_mod = self._main_mod_cache[filename] = types.ModuleType(\\n',\n",
       "  '                        py3compat.cast_bytes_py2(modname),\\n',\n",
       "  '                        doc=\"Module created for script run in IPython\")\\n',\n",
       "  '        else:\\n',\n",
       "  '            main_mod.__dict__.clear()\\n',\n",
       "  '            main_mod.__name__ = modname\\n',\n",
       "  '        \\n',\n",
       "  '        main_mod.__file__ = filename\\n',\n",
       "  '        # It seems pydoc (and perhaps others) needs any module instance to\\n',\n",
       "  '        # implement a __nonzero__ method\\n',\n",
       "  '        main_mod.__nonzero__ = lambda : True\\n',\n",
       "  '        \\n',\n",
       "  '        return main_mod\\n',\n",
       "  '\\n',\n",
       "  '    def clear_main_mod_cache(self):\\n',\n",
       "  '        \"\"\"Clear the cache of main modules.\\n',\n",
       "  '\\n',\n",
       "  '        Mainly for use by utilities like %reset.\\n',\n",
       "  '\\n',\n",
       "  '        Examples\\n',\n",
       "  '        --------\\n',\n",
       "  '\\n',\n",
       "  '        In [15]: import IPython\\n',\n",
       "  '\\n',\n",
       "  \"        In [16]: m = _ip.new_main_mod(IPython.__file__, 'IPython')\\n\",\n",
       "  '\\n',\n",
       "  '        In [17]: len(_ip._main_mod_cache) > 0\\n',\n",
       "  '        Out[17]: True\\n',\n",
       "  '\\n',\n",
       "  '        In [18]: _ip.clear_main_mod_cache()\\n',\n",
       "  '\\n',\n",
       "  '        In [19]: len(_ip._main_mod_cache) == 0\\n',\n",
       "  '        Out[19]: True\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        self._main_mod_cache.clear()\\n',\n",
       "  '\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '    # Things related to debugging\\n',\n",
       "  '    #-------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '    def init_pdb(self):\\n',\n",
       "  '        # Set calling of pdb on exceptions\\n',\n",
       "  '        # self.call_pdb is a property\\n',\n",
       "  '        self.call_pdb = self.pdb\\n',\n",
       "  '\\n',\n",
       "  '    def _get_call_pdb(self):\\n',\n",
       "  '        return self._call_pdb\\n',\n",
       "  '\\n',\n",
       "  '    def _set_call_pdb(self,val):\\n',\n",
       "  '\\n',\n",
       "  '        if val not in (0,1,False,True):\\n',\n",
       "  \"            raise ValueError('new call_pdb value must be boolean')\\n\",\n",
       "  '\\n',\n",
       "  '        # store value in instance\\n',\n",
       "  '        self._call_pdb = val\\n',\n",
       "  '\\n',\n",
       "  '        # notify the actual exception handlers\\n',\n",
       "  '        self.InteractiveTB.call_pdb = val\\n',\n",
       "  '\\n',\n",
       "  '    call_pdb = property(_get_call_pdb,_set_call_pdb,None,\\n',\n",
       "  \"                        'Control auto-activation of pdb at exceptions')\\n\",\n",
       "  '\\n',\n",
       "  '    def debugger(self,force=False):\\n',\n",
       "  '        \"\"\"Call the pydb/pdb debugger.\\n',\n",
       "  '\\n',\n",
       "  '        Keywords:\\n',\n",
       "  '\\n',\n",
       "  '          - force(False): by default, this routine checks the instance call_pdb\\n',\n",
       "  '            flag and does not actually invoke the debugger if the flag is false.\\n',\n",
       "  \"            The 'force' option forces the debugger to activate even if the flag\\n\",\n",
       "  '            is false.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '        if not (force or self.call_pdb):\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  \"        if not hasattr(sys,'last_traceback'):\\n\",\n",
       "  \"            error('No traceback has been produced, nothing to debug.')\\n\",\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        # use pydb if available\\n',\n",
       "  '        if debugger.has_pydb:\\n',\n",
       "  '            from pydb import pm\\n',\n",
       "  '        else:\\n',\n",
       "  '            # fallback to our internal debugger\\n',\n",
       "  '            pm = lambda : self.InteractiveTB.debugger(force=True)\\n',\n",
       "  '\\n',\n",
       "  ...],\n",
       " Path('/home/pasha/.ipython/profile_default/db'),\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " ['\"\"\" History related magics and functionality \"\"\"\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '#  Copyright (C) 2010-2011 The IPython Development Team.\\n',\n",
       "  '#\\n',\n",
       "  '#  Distributed under the terms of the BSD License.\\n',\n",
       "  '#\\n',\n",
       "  '#  The full license is in the file COPYING.txt, distributed with this software.\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '# Imports\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  'from __future__ import print_function\\n',\n",
       "  '\\n',\n",
       "  '# Stdlib imports\\n',\n",
       "  'import atexit\\n',\n",
       "  'import datetime\\n',\n",
       "  'import os\\n',\n",
       "  'import re\\n',\n",
       "  'try:\\n',\n",
       "  '    import sqlite3\\n',\n",
       "  'except ImportError:\\n',\n",
       "  '    try:\\n',\n",
       "  '        from pysqlite2 import dbapi2 as sqlite3\\n',\n",
       "  '    except ImportError:\\n',\n",
       "  '        sqlite3 = None\\n',\n",
       "  'import threading\\n',\n",
       "  '\\n',\n",
       "  '# Our own packages\\n',\n",
       "  'from traitlets.config.configurable import Configurable\\n',\n",
       "  'from decorator import decorator\\n',\n",
       "  'from IPython.utils.decorators import undoc\\n',\n",
       "  'from IPython.utils.path import locate_profile\\n',\n",
       "  'from IPython.utils import py3compat\\n',\n",
       "  'from traitlets import (\\n',\n",
       "  '    Any, Bool, Dict, Instance, Integer, List, Unicode, TraitError,\\n',\n",
       "  ')\\n',\n",
       "  'from IPython.utils.warn import warn\\n',\n",
       "  '\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '# Classes and functions\\n',\n",
       "  '#-----------------------------------------------------------------------------\\n',\n",
       "  '\\n',\n",
       "  '@undoc\\n',\n",
       "  'class DummyDB(object):\\n',\n",
       "  '    \"\"\"Dummy DB that will act as a black hole for history.\\n',\n",
       "  '    \\n',\n",
       "  '    Only used in the absence of sqlite\"\"\"\\n',\n",
       "  '    def execute(*args, **kwargs):\\n',\n",
       "  '        return []\\n',\n",
       "  '    \\n',\n",
       "  '    def commit(self, *args, **kwargs):\\n',\n",
       "  '        pass\\n',\n",
       "  '    \\n',\n",
       "  '    def __enter__(self, *args, **kwargs):\\n',\n",
       "  '        pass\\n',\n",
       "  '    \\n',\n",
       "  '    def __exit__(self, *args, **kwargs):\\n',\n",
       "  '        pass\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '@decorator\\n',\n",
       "  'def needs_sqlite(f, self, *a, **kw):\\n',\n",
       "  '    \"\"\"Decorator: return an empty list in the absence of sqlite.\"\"\"\\n',\n",
       "  '    if sqlite3 is None or not self.enabled:\\n',\n",
       "  '        return []\\n',\n",
       "  '    else:\\n',\n",
       "  '        return f(self, *a, **kw)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'if sqlite3 is not None:\\n',\n",
       "  '    DatabaseError = sqlite3.DatabaseError\\n',\n",
       "  '    OperationalError = sqlite3.OperationalError\\n',\n",
       "  'else:\\n',\n",
       "  '    @undoc\\n',\n",
       "  '    class DatabaseError(Exception):\\n',\n",
       "  '        \"Dummy exception when sqlite could not be imported. Should never occur.\"\\n',\n",
       "  '    \\n',\n",
       "  '    @undoc\\n',\n",
       "  '    class OperationalError(Exception):\\n',\n",
       "  '        \"Dummy exception when sqlite could not be imported. Should never occur.\"\\n',\n",
       "  '\\n',\n",
       "  '@decorator\\n',\n",
       "  'def catch_corrupt_db(f, self, *a, **kw):\\n',\n",
       "  '    \"\"\"A decorator which wraps HistoryAccessor method calls to catch errors from\\n',\n",
       "  '    a corrupt SQLite database, move the old database out of the way, and create\\n',\n",
       "  '    a new one.\\n',\n",
       "  '    \"\"\"\\n',\n",
       "  '    try:\\n',\n",
       "  '        return f(self, *a, **kw)\\n',\n",
       "  '    except (DatabaseError, OperationalError):\\n',\n",
       "  '        if os.path.isfile(self.hist_file):\\n',\n",
       "  '            # Try to move the file out of the way\\n',\n",
       "  '            base,ext = os.path.splitext(self.hist_file)\\n',\n",
       "  \"            newpath = base + '-corrupt' + ext\\n\",\n",
       "  '            os.rename(self.hist_file, newpath)\\n',\n",
       "  '            self.init_db()\\n',\n",
       "  '            print(\"ERROR! History file wasn\\'t a valid SQLite database.\",\\n',\n",
       "  '            \"It was moved to %s\" % newpath, \"and a new file created.\")\\n',\n",
       "  '            return []\\n',\n",
       "  '        \\n',\n",
       "  '        else:\\n',\n",
       "  '            # The hist_file is probably :memory: or something else.\\n',\n",
       "  '            raise\\n',\n",
       "  '        \\n',\n",
       "  'class HistoryAccessorBase(Configurable):\\n',\n",
       "  '    \"\"\"An abstract class for History Accessors \"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    def get_tail(self, n=10, raw=True, output=False, include_latest=False):\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    def search(self, pattern=\"*\", raw=True, search_raw=True,\\n',\n",
       "  '               output=False, n=None, unique=False):\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    def get_range(self, session, start=1, stop=None, raw=True,output=False):\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '    def get_range_by_str(self, rangestr, raw=True, output=False):\\n',\n",
       "  '        raise NotImplementedError\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class HistoryAccessor(HistoryAccessorBase):\\n',\n",
       "  '    \"\"\"Access the history database without adding to it.\\n',\n",
       "  '    \\n',\n",
       "  '    This is intended for use by standalone history tools. IPython shells use\\n',\n",
       "  '    HistoryManager, below, which is a subclass of this.\"\"\"\\n',\n",
       "  '\\n',\n",
       "  '    # String holding the path to the history file\\n',\n",
       "  '    hist_file = Unicode(config=True,\\n',\n",
       "  '        help=\"\"\"Path to file to use for SQLite history database.\\n',\n",
       "  '        \\n',\n",
       "  '        By default, IPython will put the history database in the IPython\\n',\n",
       "  '        profile directory.  If you would rather share one history among\\n',\n",
       "  '        profiles, you can set this value in each, so that they are consistent.\\n',\n",
       "  '        \\n',\n",
       "  '        Due to an issue with fcntl, SQLite is known to misbehave on some NFS\\n',\n",
       "  '        mounts.  If you see IPython hanging, try setting this to something on a\\n',\n",
       "  '        local disk, e.g::\\n',\n",
       "  '        \\n',\n",
       "  '            ipython --HistoryManager.hist_file=/tmp/ipython_hist.sqlite\\n',\n",
       "  '        \\n',\n",
       "  '        \"\"\")\\n',\n",
       "  '    \\n',\n",
       "  '    enabled = Bool(True, config=True,\\n',\n",
       "  '        help=\"\"\"enable the SQLite history\\n',\n",
       "  '        \\n',\n",
       "  '        set enabled=False to disable the SQLite history,\\n',\n",
       "  '        in which case there will be no stored history, no SQLite connection,\\n',\n",
       "  '        and no background saving thread.  This may be necessary in some\\n',\n",
       "  '        threaded environments where IPython is embedded.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '    \\n',\n",
       "  '    connection_options = Dict(config=True,\\n',\n",
       "  '        help=\"\"\"Options for configuring the SQLite connection\\n',\n",
       "  '        \\n',\n",
       "  '        These options are passed as keyword args to sqlite3.connect\\n',\n",
       "  '        when establishing database conenctions.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '    )\\n',\n",
       "  '\\n',\n",
       "  '    # The SQLite database\\n',\n",
       "  '    db = Any()\\n',\n",
       "  '    def _db_changed(self, name, old, new):\\n',\n",
       "  '        \"\"\"validate the db, since it can be an Instance of two different types\"\"\"\\n',\n",
       "  '        connection_types = (DummyDB,)\\n',\n",
       "  '        if sqlite3 is not None:\\n',\n",
       "  '            connection_types = (DummyDB, sqlite3.Connection)\\n',\n",
       "  '        if not isinstance(new, connection_types):\\n',\n",
       "  '            msg = \"%s.db must be sqlite3 Connection or DummyDB, not %r\" % \\\\\\n',\n",
       "  '                    (self.__class__.__name__, new)\\n',\n",
       "  '            raise TraitError(msg)\\n',\n",
       "  '    \\n',\n",
       "  \"    def __init__(self, profile='default', hist_file=u'', **traits):\\n\",\n",
       "  '        \"\"\"Create a new history accessor.\\n',\n",
       "  '        \\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        profile : str\\n',\n",
       "  '          The name of the profile from which to open history.\\n',\n",
       "  '        hist_file : str\\n',\n",
       "  '          Path to an SQLite history database stored by IPython. If specified,\\n',\n",
       "  '          hist_file overrides profile.\\n',\n",
       "  '        config : :class:`~traitlets.config.loader.Config`\\n',\n",
       "  '          Config object. hist_file can also be set through this.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        # We need a pointer back to the shell for various tasks.\\n',\n",
       "  '        super(HistoryAccessor, self).__init__(**traits)\\n',\n",
       "  '        # defer setting hist_file from kwarg until after init,\\n',\n",
       "  '        # otherwise the default kwarg value would clobber any value\\n',\n",
       "  '        # set by config\\n',\n",
       "  '        if hist_file:\\n',\n",
       "  '            self.hist_file = hist_file\\n',\n",
       "  '        \\n',\n",
       "  \"        if self.hist_file == u'':\\n\",\n",
       "  '            # No one has set the hist_file, yet.\\n',\n",
       "  '            self.hist_file = self._get_hist_file_name(profile)\\n',\n",
       "  '\\n',\n",
       "  '        if sqlite3 is None and self.enabled:\\n',\n",
       "  '            warn(\"IPython History requires SQLite, your history will not be saved\")\\n',\n",
       "  '            self.enabled = False\\n',\n",
       "  '        \\n',\n",
       "  '        self.init_db()\\n',\n",
       "  '    \\n',\n",
       "  \"    def _get_hist_file_name(self, profile='default'):\\n\",\n",
       "  '        \"\"\"Find the history file for the given profile name.\\n',\n",
       "  '        \\n',\n",
       "  \"        This is overridden by the HistoryManager subclass, to use the shell's\\n\",\n",
       "  '        active profile.\\n',\n",
       "  '        \\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        profile : str\\n',\n",
       "  '          The name of a profile which has a history file.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        return os.path.join(locate_profile(profile), 'history.sqlite')\\n\",\n",
       "  '    \\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def init_db(self):\\n',\n",
       "  '        \"\"\"Connect to the database, and create tables if necessary.\"\"\"\\n',\n",
       "  '        if not self.enabled:\\n',\n",
       "  '            self.db = DummyDB()\\n',\n",
       "  '            return\\n',\n",
       "  '        \\n',\n",
       "  '        # use detect_types so that timestamps return datetime objects\\n',\n",
       "  '        kwargs = dict(detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)\\n',\n",
       "  '        kwargs.update(self.connection_options)\\n',\n",
       "  '        self.db = sqlite3.connect(self.hist_file, **kwargs)\\n',\n",
       "  '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS sessions (session integer\\n',\n",
       "  '                        primary key autoincrement, start timestamp,\\n',\n",
       "  '                        end timestamp, num_cmds integer, remark text)\"\"\")\\n',\n",
       "  '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS history\\n',\n",
       "  '                (session integer, line integer, source text, source_raw text,\\n',\n",
       "  '                PRIMARY KEY (session, line))\"\"\")\\n',\n",
       "  \"        # Output history is optional, but ensure the table's there so it can be\\n\",\n",
       "  '        # enabled later.\\n',\n",
       "  '        self.db.execute(\"\"\"CREATE TABLE IF NOT EXISTS output_history\\n',\n",
       "  '                        (session integer, line integer, output text,\\n',\n",
       "  '                        PRIMARY KEY (session, line))\"\"\")\\n',\n",
       "  '        self.db.commit()\\n',\n",
       "  '\\n',\n",
       "  '    def writeout_cache(self):\\n',\n",
       "  '        \"\"\"Overridden by HistoryManager to dump the cache before certain\\n',\n",
       "  '        database lookups.\"\"\"\\n',\n",
       "  '        pass\\n',\n",
       "  '\\n',\n",
       "  '    ## -------------------------------\\n',\n",
       "  '    ## Methods for retrieving history:\\n',\n",
       "  '    ## -------------------------------\\n',\n",
       "  '    def _run_sql(self, sql, params, raw=True, output=False):\\n',\n",
       "  '        \"\"\"Prepares and runs an SQL query for the history database.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        sql : str\\n',\n",
       "  '          Any filtering expressions to go after SELECT ... FROM ...\\n',\n",
       "  '        params : tuple\\n',\n",
       "  '          Parameters passed to the SQL query (to replace \"?\")\\n',\n",
       "  '        raw, output : bool\\n',\n",
       "  '          See :meth:`get_range`\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        Tuples as :meth:`get_range`\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  \"        toget = 'source_raw' if raw else 'source'\\n\",\n",
       "  '        sqlfrom = \"history\"\\n',\n",
       "  '        if output:\\n',\n",
       "  '            sqlfrom = \"history LEFT JOIN output_history USING (session, line)\"\\n',\n",
       "  '            toget = \"history.%s, output_history.output\" % toget\\n',\n",
       "  '        cur = self.db.execute(\"SELECT session, line, %s FROM %s \" %\\\\\\n',\n",
       "  '                                (toget, sqlfrom) + sql, params)\\n',\n",
       "  '        if output:    # Regroup into 3-tuples, and parse JSON\\n',\n",
       "  '            return ((ses, lin, (inp, out)) for ses, lin, inp, out in cur)\\n',\n",
       "  '        return cur\\n',\n",
       "  '\\n',\n",
       "  '    @needs_sqlite\\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def get_session_info(self, session):\\n',\n",
       "  '        \"\"\"Get info about a session.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '\\n',\n",
       "  '        session : int\\n',\n",
       "  '            Session number to retrieve.\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        \\n',\n",
       "  '        session_id : int\\n',\n",
       "  '           Session ID number\\n',\n",
       "  '        start : datetime\\n',\n",
       "  '           Timestamp for the start of the session.\\n',\n",
       "  '        end : datetime\\n',\n",
       "  '           Timestamp for the end of the session, or None if IPython crashed.\\n',\n",
       "  '        num_cmds : int\\n',\n",
       "  '           Number of commands run, or None if IPython crashed.\\n',\n",
       "  '        remark : unicode\\n',\n",
       "  '           A manually set description.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        query = \"SELECT * from sessions where session == ?\"\\n',\n",
       "  '        return self.db.execute(query, (session,)).fetchone()\\n',\n",
       "  '\\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def get_last_session_id(self):\\n',\n",
       "  '        \"\"\"Get the last session ID currently in the database.\\n',\n",
       "  '        \\n',\n",
       "  '        Within IPython, this should be the same as the value stored in\\n',\n",
       "  '        :attr:`HistoryManager.session_number`.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        for record in self.get_tail(n=1, include_latest=True):\\n',\n",
       "  '            return record[0]\\n',\n",
       "  '\\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def get_tail(self, n=10, raw=True, output=False, include_latest=False):\\n',\n",
       "  '        \"\"\"Get the last n lines from the history database.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        n : int\\n',\n",
       "  '          The number of lines to get\\n',\n",
       "  '        raw, output : bool\\n',\n",
       "  '          See :meth:`get_range`\\n',\n",
       "  '        include_latest : bool\\n',\n",
       "  '          If False (default), n+1 lines are fetched, and the latest one\\n',\n",
       "  '          is discarded. This is intended to be used where the function\\n',\n",
       "  '          is called by a user command, which it should not return.\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        Tuples as :meth:`get_range`\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        self.writeout_cache()\\n',\n",
       "  '        if not include_latest:\\n',\n",
       "  '            n += 1\\n',\n",
       "  '        cur = self._run_sql(\"ORDER BY session DESC, line DESC LIMIT ?\",\\n',\n",
       "  '                                (n,), raw=raw, output=output)\\n',\n",
       "  '        if not include_latest:\\n',\n",
       "  '            return reversed(list(cur)[1:])\\n',\n",
       "  '        return reversed(list(cur))\\n',\n",
       "  '\\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def search(self, pattern=\"*\", raw=True, search_raw=True,\\n',\n",
       "  '               output=False, n=None, unique=False):\\n',\n",
       "  '        \"\"\"Search the database using unix glob-style matching (wildcards\\n',\n",
       "  '        * and ?).\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        pattern : str\\n',\n",
       "  '          The wildcarded pattern to match when searching\\n',\n",
       "  '        search_raw : bool\\n',\n",
       "  '          If True, search the raw input, otherwise, the parsed input\\n',\n",
       "  '        raw, output : bool\\n',\n",
       "  '          See :meth:`get_range`\\n',\n",
       "  '        n : None or int\\n',\n",
       "  '          If an integer is given, it defines the limit of\\n',\n",
       "  '          returned entries.\\n',\n",
       "  '        unique : bool\\n',\n",
       "  '          When it is true, return only unique entries.\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        Tuples as :meth:`get_range`\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        tosearch = \"source_raw\" if search_raw else \"source\"\\n',\n",
       "  '        if output:\\n',\n",
       "  '            tosearch = \"history.\" + tosearch\\n',\n",
       "  '        self.writeout_cache()\\n',\n",
       "  '        sqlform = \"WHERE %s GLOB ?\" % tosearch\\n',\n",
       "  '        params = (pattern,)\\n',\n",
       "  '        if unique:\\n',\n",
       "  \"            sqlform += ' GROUP BY {0}'.format(tosearch)\\n\",\n",
       "  '        if n is not None:\\n',\n",
       "  '            sqlform += \" ORDER BY session DESC, line DESC LIMIT ?\"\\n',\n",
       "  '            params += (n,)\\n',\n",
       "  '        elif unique:\\n',\n",
       "  '            sqlform += \" ORDER BY session, line\"\\n',\n",
       "  '        cur = self._run_sql(sqlform, params, raw=raw, output=output)\\n',\n",
       "  '        if n is not None:\\n',\n",
       "  '            return reversed(list(cur))\\n',\n",
       "  '        return cur\\n',\n",
       "  '    \\n',\n",
       "  '    @catch_corrupt_db\\n',\n",
       "  '    def get_range(self, session, start=1, stop=None, raw=True,output=False):\\n',\n",
       "  '        \"\"\"Retrieve input by session.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        session : int\\n',\n",
       "  '            Session number to retrieve.\\n',\n",
       "  '        start : int\\n',\n",
       "  '            First line to retrieve.\\n',\n",
       "  '        stop : int\\n',\n",
       "  '            End of line range (excluded from output itself). If None, retrieve\\n',\n",
       "  '            to the end of the session.\\n',\n",
       "  '        raw : bool\\n',\n",
       "  '            If True, return untranslated input\\n',\n",
       "  '        output : bool\\n',\n",
       "  \"            If True, attempt to include output. This will be 'real' Python\\n\",\n",
       "  '            objects for the current session, or text reprs from previous\\n',\n",
       "  '            sessions if db_log_output was enabled at the time. Where no output\\n',\n",
       "  '            is found, None is used.\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        entries\\n',\n",
       "  '          An iterator over the desired lines. Each line is a 3-tuple, either\\n',\n",
       "  '          (session, line, input) if output is False, or\\n',\n",
       "  '          (session, line, (input, output)) if output is True.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if stop:\\n',\n",
       "  '            lineclause = \"line >= ? AND line < ?\"\\n',\n",
       "  '            params = (session, start, stop)\\n',\n",
       "  '        else:\\n',\n",
       "  '            lineclause = \"line>=?\"\\n',\n",
       "  '            params = (session, start)\\n',\n",
       "  '\\n',\n",
       "  '        return self._run_sql(\"WHERE session==? AND %s\" % lineclause,\\n',\n",
       "  '                                    params, raw=raw, output=output)\\n',\n",
       "  '\\n',\n",
       "  '    def get_range_by_str(self, rangestr, raw=True, output=False):\\n',\n",
       "  '        \"\"\"Get lines of history from a string of ranges, as used by magic\\n',\n",
       "  '        commands %hist, %save, %macro, etc.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        rangestr : str\\n',\n",
       "  '          A string specifying ranges, e.g. \"5 ~2/1-4\". See\\n',\n",
       "  '          :func:`magic_history` for full details.\\n',\n",
       "  '        raw, output : bool\\n',\n",
       "  '          As :meth:`get_range`\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        Tuples as :meth:`get_range`\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        for sess, s, e in extract_hist_ranges(rangestr):\\n',\n",
       "  '            for line in self.get_range(sess, s, e, raw=raw, output=output):\\n',\n",
       "  '                yield line\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class HistoryManager(HistoryAccessor):\\n',\n",
       "  '    \"\"\"A class to organize all history-related functionality in one place.\\n',\n",
       "  '    \"\"\"\\n',\n",
       "  '    # Public interface\\n',\n",
       "  '\\n',\n",
       "  '    # An instance of the IPython shell we are attached to\\n',\n",
       "  \"    shell = Instance('IPython.core.interactiveshell.InteractiveShellABC',\\n\",\n",
       "  '                     allow_none=True)\\n',\n",
       "  '    # Lists to hold processed and raw history. These start with a blank entry\\n',\n",
       "  '    # so that we can index them starting from 1\\n',\n",
       "  '    input_hist_parsed = List([\"\"])\\n',\n",
       "  '    input_hist_raw = List([\"\"])\\n',\n",
       "  '    # A list of directories visited during session\\n',\n",
       "  '    dir_hist = List()\\n',\n",
       "  '    def _dir_hist_default(self):\\n',\n",
       "  '        try:\\n',\n",
       "  '            return [py3compat.getcwd()]\\n',\n",
       "  '        except OSError:\\n',\n",
       "  '            return []\\n',\n",
       "  '\\n',\n",
       "  \"    # A dict of output history, keyed with ints from the shell's\\n\",\n",
       "  '    # execution count.\\n',\n",
       "  '    output_hist = Dict()\\n',\n",
       "  '    # The text/plain repr of outputs.\\n',\n",
       "  '    output_hist_reprs = Dict()\\n',\n",
       "  '\\n',\n",
       "  '    # The number of the current session in the history database\\n',\n",
       "  '    session_number = Integer()\\n',\n",
       "  '    \\n',\n",
       "  '    db_log_output = Bool(False, config=True,\\n',\n",
       "  '        help=\"Should the history database include output? (default: no)\"\\n',\n",
       "  '    )\\n',\n",
       "  '    db_cache_size = Integer(0, config=True,\\n',\n",
       "  '        help=\"Write to database every x commands (higher values save disk access & power).\\\\n\"\\n',\n",
       "  '        \"Values of 1 or less effectively disable caching.\"\\n',\n",
       "  '    )\\n',\n",
       "  '    # The input and output caches\\n',\n",
       "  '    db_input_cache = List()\\n',\n",
       "  '    db_output_cache = List()\\n',\n",
       "  '    \\n',\n",
       "  '    # History saving in separate thread\\n',\n",
       "  \"    save_thread = Instance('IPython.core.history.HistorySavingThread',\\n\",\n",
       "  '                           allow_none=True)\\n',\n",
       "  '    try:               # Event is a function returning an instance of _Event...\\n',\n",
       "  '        save_flag = Instance(threading._Event, allow_none=True)\\n',\n",
       "  \"    except AttributeError:         # ...until Python 3.3, when it's a class.\\n\",\n",
       "  '        save_flag = Instance(threading.Event, allow_none=True)\\n',\n",
       "  '    \\n',\n",
       "  '    # Private interface\\n',\n",
       "  '    # Variables used to store the three last inputs from the user.  On each new\\n',\n",
       "  \"    # history update, we populate the user's namespace with these, shifted as\\n\",\n",
       "  '    # necessary.\\n',\n",
       "  \"    _i00 = Unicode(u'')\\n\",\n",
       "  \"    _i = Unicode(u'')\\n\",\n",
       "  \"    _ii = Unicode(u'')\\n\",\n",
       "  \"    _iii = Unicode(u'')\\n\",\n",
       "  '\\n',\n",
       "  \"    # A regex matching all forms of the exit command, so that we don't store\\n\",\n",
       "  \"    # them in the history (it's annoying to rewind the first entry and land on\\n\",\n",
       "  '    # an exit call).\\n',\n",
       "  '    _exit_re = re.compile(r\"(exit|quit)(\\\\s*\\\\(.*\\\\))?$\")\\n',\n",
       "  '\\n',\n",
       "  '    def __init__(self, shell=None, config=None, **traits):\\n',\n",
       "  '        \"\"\"Create a new history manager associated with a shell instance.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        # We need a pointer back to the shell for various tasks.\\n',\n",
       "  '        super(HistoryManager, self).__init__(shell=shell, config=config,\\n',\n",
       "  '            **traits)\\n',\n",
       "  '        self.save_flag = threading.Event()\\n',\n",
       "  '        self.db_input_cache_lock = threading.Lock()\\n',\n",
       "  '        self.db_output_cache_lock = threading.Lock()\\n',\n",
       "  '        \\n',\n",
       "  '        try:\\n',\n",
       "  '            self.new_session()\\n',\n",
       "  '        except OperationalError:\\n',\n",
       "  '            self.log.error(\"Failed to create history session in %s. History will not be saved.\",\\n',\n",
       "  '                self.hist_file, exc_info=True)\\n',\n",
       "  \"            self.hist_file = ':memory:'\\n\",\n",
       "  '        \\n',\n",
       "  \"        if self.enabled and self.hist_file != ':memory:':\\n\",\n",
       "  '            self.save_thread = HistorySavingThread(self)\\n',\n",
       "  '            self.save_thread.start()\\n',\n",
       "  '\\n',\n",
       "  '    def _get_hist_file_name(self, profile=None):\\n',\n",
       "  '        \"\"\"Get default history file name based on the Shell\\'s profile.\\n',\n",
       "  '        \\n',\n",
       "  '        The profile parameter is ignored, but must exist for compatibility with\\n',\n",
       "  '        the parent class.\"\"\"\\n',\n",
       "  '        profile_dir = self.shell.profile_dir.location\\n',\n",
       "  \"        return os.path.join(profile_dir, 'history.sqlite')\\n\",\n",
       "  '    \\n',\n",
       "  '    @needs_sqlite\\n',\n",
       "  '    def new_session(self, conn=None):\\n',\n",
       "  '        \"\"\"Get a new session number.\"\"\"\\n',\n",
       "  '        if conn is None:\\n',\n",
       "  '            conn = self.db\\n',\n",
       "  '        \\n',\n",
       "  '        with conn:\\n',\n",
       "  '            cur = conn.execute(\"\"\"INSERT INTO sessions VALUES (NULL, ?, NULL,\\n',\n",
       "  '                            NULL, \"\") \"\"\", (datetime.datetime.now(),))\\n',\n",
       "  '            self.session_number = cur.lastrowid\\n',\n",
       "  '            \\n',\n",
       "  '    def end_session(self):\\n',\n",
       "  '        \"\"\"Close the database session, filling in the end time and line count.\"\"\"\\n',\n",
       "  '        self.writeout_cache()\\n',\n",
       "  '        with self.db:\\n',\n",
       "  '            self.db.execute(\"\"\"UPDATE sessions SET end=?, num_cmds=? WHERE\\n',\n",
       "  '                            session==?\"\"\", (datetime.datetime.now(),\\n',\n",
       "  '                            len(self.input_hist_parsed)-1, self.session_number))\\n',\n",
       "  '        self.session_number = 0\\n',\n",
       "  '                            \\n',\n",
       "  '    def name_session(self, name):\\n',\n",
       "  '        \"\"\"Give the current session a name in the history database.\"\"\"\\n',\n",
       "  '        with self.db:\\n',\n",
       "  '            self.db.execute(\"UPDATE sessions SET remark=? WHERE session==?\",\\n',\n",
       "  '                            (name, self.session_number))\\n',\n",
       "  '                            \\n',\n",
       "  '    def reset(self, new_session=True):\\n',\n",
       "  '        \"\"\"Clear the session history, releasing all object references, and\\n',\n",
       "  '        optionally open a new session.\"\"\"\\n',\n",
       "  '        self.output_hist.clear()\\n',\n",
       "  \"        # The directory history can't be completely empty\\n\",\n",
       "  '        self.dir_hist[:] = [py3compat.getcwd()]\\n',\n",
       "  '        \\n',\n",
       "  '        if new_session:\\n',\n",
       "  '            if self.session_number:\\n',\n",
       "  '                self.end_session()\\n',\n",
       "  '            self.input_hist_parsed[:] = [\"\"]\\n',\n",
       "  '            self.input_hist_raw[:] = [\"\"]\\n',\n",
       "  '            self.new_session()\\n',\n",
       "  '\\n',\n",
       "  '    # ------------------------------\\n',\n",
       "  '    # Methods for retrieving history\\n',\n",
       "  '    # ------------------------------\\n',\n",
       "  '    def get_session_info(self, session=0):\\n',\n",
       "  '        \"\"\"Get info about a session.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '\\n',\n",
       "  '        session : int\\n',\n",
       "  '            Session number to retrieve. The current session is 0, and negative\\n',\n",
       "  '            numbers count back from current session, so -1 is the previous session.\\n',\n",
       "  '\\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        \\n',\n",
       "  '        session_id : int\\n',\n",
       "  '           Session ID number\\n',\n",
       "  '        start : datetime\\n',\n",
       "  '           Timestamp for the start of the session.\\n',\n",
       "  '        end : datetime\\n',\n",
       "  '           Timestamp for the end of the session, or None if IPython crashed.\\n',\n",
       "  '        num_cmds : int\\n',\n",
       "  '           Number of commands run, or None if IPython crashed.\\n',\n",
       "  '        remark : unicode\\n',\n",
       "  '           A manually set description.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if session <= 0:\\n',\n",
       "  '            session += self.session_number\\n',\n",
       "  '\\n',\n",
       "  '        return super(HistoryManager, self).get_session_info(session=session)\\n',\n",
       "  '\\n',\n",
       "  '    def _get_range_session(self, start=1, stop=None, raw=True, output=False):\\n',\n",
       "  '        \"\"\"Get input and output history from the current session. Called by\\n',\n",
       "  '        get_range, and takes similar parameters.\"\"\"\\n',\n",
       "  '        input_hist = self.input_hist_raw if raw else self.input_hist_parsed\\n',\n",
       "  '            \\n',\n",
       "  '        n = len(input_hist)\\n',\n",
       "  '        if start < 0:\\n',\n",
       "  '            start += n\\n',\n",
       "  '        if not stop or (stop > n):\\n',\n",
       "  '            stop = n\\n',\n",
       "  '        elif stop < 0:\\n',\n",
       "  '            stop += n\\n',\n",
       "  '        \\n',\n",
       "  '        for i in range(start, stop):\\n',\n",
       "  '            if output:\\n',\n",
       "  '                line = (input_hist[i], self.output_hist_reprs.get(i))\\n',\n",
       "  '            else:\\n',\n",
       "  '                line = input_hist[i]\\n',\n",
       "  '            yield (0, i, line)\\n',\n",
       "  '    \\n',\n",
       "  '    def get_range(self, session=0, start=1, stop=None, raw=True,output=False):\\n',\n",
       "  '        \"\"\"Retrieve input by session.\\n',\n",
       "  '        \\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        session : int\\n',\n",
       "  '            Session number to retrieve. The current session is 0, and negative\\n',\n",
       "  '            numbers count back from current session, so -1 is previous session.\\n',\n",
       "  '        start : int\\n',\n",
       "  '            First line to retrieve.\\n',\n",
       "  '        stop : int\\n',\n",
       "  '            End of line range (excluded from output itself). If None, retrieve\\n',\n",
       "  '            to the end of the session.\\n',\n",
       "  '        raw : bool\\n',\n",
       "  '            If True, return untranslated input\\n',\n",
       "  '        output : bool\\n',\n",
       "  \"            If True, attempt to include output. This will be 'real' Python\\n\",\n",
       "  '            objects for the current session, or text reprs from previous\\n',\n",
       "  '            sessions if db_log_output was enabled at the time. Where no output\\n',\n",
       "  '            is found, None is used.\\n',\n",
       "  '            \\n',\n",
       "  '        Returns\\n',\n",
       "  '        -------\\n',\n",
       "  '        entries\\n',\n",
       "  '          An iterator over the desired lines. Each line is a 3-tuple, either\\n',\n",
       "  '          (session, line, input) if output is False, or\\n',\n",
       "  '          (session, line, (input, output)) if output is True.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if session <= 0:\\n',\n",
       "  '            session += self.session_number\\n',\n",
       "  '        if session==self.session_number:          # Current session\\n',\n",
       "  '            return self._get_range_session(start, stop, raw, output)\\n',\n",
       "  '        return super(HistoryManager, self).get_range(session, start, stop, raw,\\n',\n",
       "  '                                                     output)\\n',\n",
       "  '\\n',\n",
       "  '    ## ----------------------------\\n',\n",
       "  '    ## Methods for storing history:\\n',\n",
       "  '    ## ----------------------------\\n',\n",
       "  '    def store_inputs(self, line_num, source, source_raw=None):\\n',\n",
       "  '        \"\"\"Store source and raw input in history and create input cache\\n',\n",
       "  '        variables ``_i*``.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        line_num : int\\n',\n",
       "  '          The prompt number of this input.\\n',\n",
       "  '\\n',\n",
       "  '        source : str\\n',\n",
       "  '          Python input.\\n',\n",
       "  '\\n',\n",
       "  '        source_raw : str, optional\\n',\n",
       "  '          If given, this is the raw input without any IPython transformations\\n',\n",
       "  '          applied to it.  If not given, ``source`` is used.\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if source_raw is None:\\n',\n",
       "  '            source_raw = source\\n',\n",
       "  \"        source = source.rstrip('\\\\n')\\n\",\n",
       "  \"        source_raw = source_raw.rstrip('\\\\n')\\n\",\n",
       "  '\\n',\n",
       "  '        # do not store exit/quit commands\\n',\n",
       "  '        if self._exit_re.match(source_raw.strip()):\\n',\n",
       "  '            return\\n',\n",
       "  '\\n',\n",
       "  '        self.input_hist_parsed.append(source)\\n',\n",
       "  '        self.input_hist_raw.append(source_raw)\\n',\n",
       "  '\\n',\n",
       "  '        with self.db_input_cache_lock:\\n',\n",
       "  '            self.db_input_cache.append((line_num, source, source_raw))\\n',\n",
       "  '            # Trigger to flush cache and write to DB.\\n',\n",
       "  '            if len(self.db_input_cache) >= self.db_cache_size:\\n',\n",
       "  '                self.save_flag.set()\\n',\n",
       "  '\\n',\n",
       "  '        # update the auto _i variables\\n',\n",
       "  '        self._iii = self._ii\\n',\n",
       "  '        self._ii = self._i\\n',\n",
       "  '        self._i = self._i00\\n',\n",
       "  '        self._i00 = source_raw\\n',\n",
       "  '\\n',\n",
       "  '        # hackish access to user namespace to create _i1,_i2... dynamically\\n',\n",
       "  \"        new_i = '_i%s' % line_num\\n\",\n",
       "  \"        to_main = {'_i': self._i,\\n\",\n",
       "  \"                   '_ii': self._ii,\\n\",\n",
       "  \"                   '_iii': self._iii,\\n\",\n",
       "  '                   new_i : self._i00 }\\n',\n",
       "  '        \\n',\n",
       "  '        if self.shell is not None:\\n',\n",
       "  '            self.shell.push(to_main, interactive=False)\\n',\n",
       "  '\\n',\n",
       "  '    def store_output(self, line_num):\\n',\n",
       "  '        \"\"\"If database output logging is enabled, this saves all the\\n',\n",
       "  \"        outputs from the indicated prompt number to the database. It's\\n\",\n",
       "  '        called by run_cell after code has been executed.\\n',\n",
       "  '\\n',\n",
       "  '        Parameters\\n',\n",
       "  '        ----------\\n',\n",
       "  '        line_num : int\\n',\n",
       "  '          The line number from which to save outputs\\n',\n",
       "  '        \"\"\"\\n',\n",
       "  '        if (not self.db_log_output) or (line_num not in self.output_hist_reprs):\\n',\n",
       "  '            return\\n',\n",
       "  '        output = self.output_hist_reprs[line_num]\\n',\n",
       "  '\\n',\n",
       "  '        with self.db_output_cache_lock:\\n',\n",
       "  '            self.db_output_cache.append((line_num, output))\\n',\n",
       "  '        if self.db_cache_size <= 1:\\n',\n",
       "  '            self.save_flag.set()\\n',\n",
       "  '\\n',\n",
       "  '    def _writeout_input_cache(self, conn):\\n',\n",
       "  '        with conn:\\n',\n",
       "  '            for line in self.db_input_cache:\\n',\n",
       "  '                conn.execute(\"INSERT INTO history VALUES (?, ?, ?, ?)\",\\n',\n",
       "  '                                (self.session_number,)+line)\\n',\n",
       "  '\\n',\n",
       "  '    def _writeout_output_cache(self, conn):\\n',\n",
       "  '        with conn:\\n',\n",
       "  '            for line in self.db_output_cache:\\n',\n",
       "  '                conn.execute(\"INSERT INTO output_history VALUES (?, ?, ?)\",\\n',\n",
       "  '                                (self.session_number,)+line)\\n',\n",
       "  '\\n',\n",
       "  '    @needs_sqlite\\n',\n",
       "  '    def writeout_cache(self, conn=None):\\n',\n",
       "  '        \"\"\"Write any entries in the cache to the database.\"\"\"\\n',\n",
       "  '        if conn is None:\\n',\n",
       "  '            conn = self.db\\n',\n",
       "  '\\n',\n",
       "  '        with self.db_input_cache_lock:\\n',\n",
       "  '            try:\\n',\n",
       "  '                self._writeout_input_cache(conn)\\n',\n",
       "  '            except sqlite3.IntegrityError:\\n',\n",
       "  '                self.new_session(conn)\\n',\n",
       "  '                print(\"ERROR! Session/line number was not unique in\",\\n',\n",
       "  '                      \"database. History logging moved to new session\",\\n',\n",
       "  '                                                self.session_number)\\n',\n",
       "  '                try:\\n',\n",
       "  \"                    # Try writing to the new session. If this fails, don't\\n\",\n",
       "  '                    # recurse\\n',\n",
       "  '                    self._writeout_input_cache(conn)\\n',\n",
       "  '                except sqlite3.IntegrityError:\\n',\n",
       "  '                    pass\\n',\n",
       "  '            finally:\\n',\n",
       "  '                self.db_input_cache = []\\n',\n",
       "  '\\n',\n",
       "  '        with self.db_output_cache_lock:\\n',\n",
       "  '            try:\\n',\n",
       "  '                self._writeout_output_cache(conn)\\n',\n",
       "  '            except sqlite3.IntegrityError:\\n',\n",
       "  '                print(\"!! Session/line number for output was not unique\",\\n',\n",
       "  '                      \"in database. Output will not be stored.\")\\n',\n",
       "  '            finally:\\n',\n",
       "  '                self.db_output_cache = []\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'class HistorySavingThread(threading.Thread):\\n',\n",
       "  '    \"\"\"This thread takes care of writing history to the database, so that\\n',\n",
       "  \"    the UI isn't held up while that happens.\\n\",\n",
       "  '\\n',\n",
       "  \"    It waits for the HistoryManager's save_flag to be set, then writes out\\n\",\n",
       "  '    the history cache. The main thread is responsible for setting the flag when\\n',\n",
       "  '    the cache size reaches a defined threshold.\"\"\"\\n',\n",
       "  '    daemon = True\\n',\n",
       "  '    stop_now = False\\n',\n",
       "  '    enabled = True\\n',\n",
       "  '    def __init__(self, history_manager):\\n',\n",
       "  '        super(HistorySavingThread, self).__init__(name=\"IPythonHistorySavingThread\")\\n',\n",
       "  '        self.history_manager = history_manager\\n',\n",
       "  '        self.enabled = history_manager.enabled\\n',\n",
       "  '        atexit.register(self.stop)\\n',\n",
       "  '\\n',\n",
       "  '    @needs_sqlite\\n',\n",
       "  '    def run(self):\\n',\n",
       "  '        # We need a separate db connection per thread:\\n',\n",
       "  '        try:\\n',\n",
       "  '            self.db = sqlite3.connect(self.history_manager.hist_file,\\n',\n",
       "  '                            **self.history_manager.connection_options\\n',\n",
       "  '            )\\n',\n",
       "  '            while True:\\n',\n",
       "  '                self.history_manager.save_flag.wait()\\n',\n",
       "  '                if self.stop_now:\\n',\n",
       "  '                    self.db.close()\\n',\n",
       "  '                    return\\n',\n",
       "  '                self.history_manager.save_flag.clear()\\n',\n",
       "  '                self.history_manager.writeout_cache(self.db)\\n',\n",
       "  '        except Exception as e:\\n',\n",
       "  '            print((\"The history saving thread hit an unexpected error (%s).\"\\n',\n",
       "  '                   \"History will not be written to the database.\") % repr(e))\\n',\n",
       "  '\\n',\n",
       "  '    def stop(self):\\n',\n",
       "  '        \"\"\"This can be called from the main thread to safely stop this thread.\\n',\n",
       "  '\\n',\n",
       "  '        Note that it does not attempt to write out remaining history before\\n',\n",
       "  \"        exiting. That should be done by calling the HistoryManager's\\n\",\n",
       "  '        end_session method.\"\"\"\\n',\n",
       "  '        self.stop_now = True\\n',\n",
       "  '        self.history_manager.save_flag.set()\\n',\n",
       "  '        self.join()\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  '# To match, e.g. ~5/8-~2/3\\n',\n",
       "  'range_re = re.compile(r\"\"\"\\n',\n",
       "  '((?P<startsess>~?\\\\d+)/)?\\n',\n",
       "  '(?P<start>\\\\d+)?\\n',\n",
       "  '((?P<sep>[\\\\-:])\\n',\n",
       "  ' ((?P<endsess>~?\\\\d+)/)?\\n',\n",
       "  ' (?P<end>\\\\d+))?\\n',\n",
       "  '$\"\"\", re.VERBOSE)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'def extract_hist_ranges(ranges_str):\\n',\n",
       "  '    \"\"\"Turn a string of history ranges into 3-tuples of (session, start, stop).\\n',\n",
       "  '\\n',\n",
       "  '    Examples\\n',\n",
       "  '    --------\\n',\n",
       "  '    >>> list(extract_hist_ranges(\"~8/5-~7/4 2\"))\\n',\n",
       "  '    [(-8, 5, None), (-7, 1, 5), (0, 2, 3)]\\n',\n",
       "  '    \"\"\"\\n',\n",
       "  '    for range_str in ranges_str.split():\\n',\n",
       "  '        rmatch = range_re.match(range_str)\\n',\n",
       "  '        if not rmatch:\\n',\n",
       "  '            continue\\n',\n",
       "  '        start = rmatch.group(\"start\")\\n',\n",
       "  '        if start:\\n',\n",
       "  '            start = int(start)\\n',\n",
       "  '            end = rmatch.group(\"end\")\\n',\n",
       "  '            # If no end specified, get (a, a + 1)\\n',\n",
       "  '            end = int(end) if end else start + 1\\n',\n",
       "  '        else:  # start not specified\\n',\n",
       "  \"            if not rmatch.group('startsess'):  # no startsess\\n\",\n",
       "  '                continue\\n',\n",
       "  '            start = 1\\n',\n",
       "  '            end = None  # provide the entire session hist\\n',\n",
       "  '\\n',\n",
       "  '        if rmatch.group(\"sep\") == \"-\":       # 1-3 == 1:4 --> [1, 2, 3]\\n',\n",
       "  '            end += 1\\n',\n",
       "  '        startsess = rmatch.group(\"startsess\") or \"0\"\\n',\n",
       "  '        endsess = rmatch.group(\"endsess\") or startsess\\n',\n",
       "  '        startsess = int(startsess.replace(\"~\",\"-\"))\\n',\n",
       "  '        endsess = int(endsess.replace(\"~\",\"-\"))\\n',\n",
       "  '        assert endsess >= startsess, \"start session must be earlier than end session\"\\n',\n",
       "  '\\n',\n",
       "  '        if endsess == startsess:\\n',\n",
       "  '            yield (startsess, start, end)\\n',\n",
       "  '            continue\\n',\n",
       "  '        # Multiple sessions in one range:\\n',\n",
       "  '        yield (startsess, start, None)\\n',\n",
       "  '        for sess in range(startsess+1, endsess):\\n',\n",
       "  '            yield (sess, 1, None)\\n',\n",
       "  '        yield (endsess, 1, end)\\n',\n",
       "  '\\n',\n",
       "  '\\n',\n",
       "  'def _format_lineno(session, line):\\n',\n",
       "  '    \"\"\"Helper function to format line numbers properly.\"\"\"\\n',\n",
       "  '    if session == 0:\\n',\n",
       "  '        return str(line)\\n',\n",
       "  '    return \"%s#%s\" % (session, line)\\n',\n",
       "  '\\n',\n",
       "  '\\n'],\n",
       " <Condition(<_thread.lock object at 0x7f51c12898a0>, 1)>,\n",
       " <Condition(<_thread.lock object at 0x7f51c12899e0>, 0)>,\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " <IPython.core.prefilter.PrefilterHandler at 0x7f51c016ea20>,\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {'_lock': <_thread.lock at 0x7f51c125c3a0>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " <cell at 0x7f51c1284588: weakref object at 0x7f51c12416d8>,\n",
       " {'_exiting': False, '_shadow': False, 'sockopts': {}},\n",
       " {'_lock': <_thread.lock at 0x7f51c1289490>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " {'_cached': None,\n",
       "  '_set_fileattr': False,\n",
       "  'loader': _frozen_importlib.BuiltinImporter,\n",
       "  'loader_state': None,\n",
       "  'name': 'faulthandler',\n",
       "  'origin': 'built-in',\n",
       "  'submodule_search_locations': None},\n",
       " <cell at 0x7f51c1284a98: builtin_function_or_method object at 0x7f51c1232cc8>,\n",
       " <cell at 0x7f51c1284ac8: builtin_function_or_method object at 0x7f51c122ee48>,\n",
       " {'_poller': <zmq.sugar.poll.Poller at 0x7f51c12212b0>},\n",
       " <function tornado.stack_context.wrap.<locals>.null_wrapper>,\n",
       " (<cell at 0x7f51c1284b88: list object at 0x7f51c122be08>,\n",
       "  <cell at 0x7f51c1284bb8: method object at 0x7f51c2476fc8>),\n",
       " (<cell at 0x7f51c1284be8: list object at 0x7f51c122bb48>,\n",
       "  <cell at 0x7f51c1284c18: method object at 0x7f51c1ffdd88>),\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'_cached': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/datapub.cpython-34.pyc',\n",
       "  '_initializing': False,\n",
       "  '_set_fileattr': True,\n",
       "  'loader': <_frozen_importlib.SourceFileLoader at 0x7f51c124b780>,\n",
       "  'loader_state': None,\n",
       "  'name': 'ipykernel.datapub',\n",
       "  'origin': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/datapub.py',\n",
       "  'submodule_search_locations': None},\n",
       " {'_cached': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/serialize.cpython-34.pyc',\n",
       "  '_initializing': False,\n",
       "  '_set_fileattr': True,\n",
       "  'loader': <_frozen_importlib.SourceFileLoader at 0x7f51c124b4a8>,\n",
       "  'loader_state': None,\n",
       "  'name': 'ipykernel.serialize',\n",
       "  'origin': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/serialize.py',\n",
       "  'submodule_search_locations': None},\n",
       " {'_cached': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/pickleutil.cpython-34.pyc',\n",
       "  '_initializing': False,\n",
       "  '_set_fileattr': True,\n",
       "  'loader': <_frozen_importlib.SourceFileLoader at 0x7f51c124b4e0>,\n",
       "  'loader_state': None,\n",
       "  'name': 'ipykernel.pickleutil',\n",
       "  'origin': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/pickleutil.py',\n",
       "  'submodule_search_locations': None},\n",
       " {'_cached': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/__pycache__/codeutil.cpython-34.pyc',\n",
       "  '_initializing': False,\n",
       "  '_set_fileattr': True,\n",
       "  'loader': <_frozen_importlib.SourceFileLoader at 0x7f51c01a6278>,\n",
       "  'loader_state': None,\n",
       "  'name': 'ipykernel.codeutil',\n",
       "  'origin': '/home/pasha/.local/lib/python3.4/site-packages/ipykernel/codeutil.py',\n",
       "  'submodule_search_locations': None},\n",
       " <attribute '__weakref__' of 'CannedObject' objects>,\n",
       " <function ipykernel.pickleutil.CannedObject.get_object>,\n",
       " <function ipykernel.pickleutil.CannedObject.__init__>,\n",
       " <attribute '__dict__' of 'CannedObject' objects>,\n",
       " <function ipykernel.pickleutil.Reference.__repr__>,\n",
       " <function ipykernel.pickleutil.Reference.get_object>,\n",
       " <function ipykernel.pickleutil.Reference.__init__>,\n",
       " <function ipykernel.pickleutil.CannedCell.get_object>,\n",
       " <function ipykernel.pickleutil.CannedCell.__init__>,\n",
       " <function ipykernel.pickleutil.CannedFunction.get_object>,\n",
       " <function ipykernel.pickleutil.CannedFunction.__init__>,\n",
       " <function ipykernel.pickleutil.CannedFunction._check_type>,\n",
       " <function ipykernel.pickleutil.CannedClass.get_object>,\n",
       " <function ipykernel.pickleutil.CannedClass.__init__>,\n",
       " <function ipykernel.pickleutil.CannedClass._check_type>,\n",
       " <function ipykernel.pickleutil.CannedArray.get_object>,\n",
       " <function ipykernel.pickleutil.CannedArray.__init__>,\n",
       " <function ipykernel.pickleutil.CannedBytes.get_object>,\n",
       " <function ipykernel.pickleutil.CannedBytes.__init__>,\n",
       " <staticmethod at 0x7f51c01a6438>,\n",
       " <traitlets.traitlets.Instance at 0x7f51c124b5f8>,\n",
       " <traitlets.traitlets.Any at 0x7f51c124b630>,\n",
       " <traitlets.traitlets.CBytes at 0x7f51c124b6d8>,\n",
       " <traitlets.traitlets.Dict at 0x7f51c124b550>,\n",
       " <function ipykernel.datapub.ZMQDataPublisher.publish_data>,\n",
       " <function ipykernel.datapub.ZMQDataPublisher.set_parent>,\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'_lock': <_thread.lock at 0x7f51c12898a0>,\n",
       "  '_waiters': deque([<_thread.lock at 0x7f51c009aa58>]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " {'_lock': <_thread.lock at 0x7f51c12899e0>,\n",
       "  '_waiters': deque([]),\n",
       "  'acquire': <function lock.acquire>,\n",
       "  'release': <function lock.release>},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'esc_strings': [],\n",
       "   'handler_name': 'normal',\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " deque([]),\n",
       " <function lock.release>,\n",
       " <function lock.acquire>,\n",
       " <weakref at 0x7f51c12416d8; to 'Context' at 0x7f51c11ee2e8>,\n",
       " deque([]),\n",
       " <function lock.release>,\n",
       " <function lock.acquire>,\n",
       " <function faulthandler.enable>,\n",
       " <function faulthandler.register>,\n",
       " <zmq.sugar.poll.Poller at 0x7f51c12212b0>,\n",
       " (<cell at 0x7f51c1284b28: list object at 0x7f51c122b0c8>,\n",
       "  <cell at 0x7f51c1284b58: function object at 0x7f51c11f7598>),\n",
       " <cell at 0x7f51c1284bb8: method object at 0x7f51c2476fc8>,\n",
       " <cell at 0x7f51c1284b88: list object at 0x7f51c122be08>,\n",
       " <cell at 0x7f51c1284c18: method object at 0x7f51c1ffdd88>,\n",
       " <cell at 0x7f51c1284be8: list object at 0x7f51c122bb48>,\n",
       " ([], None),\n",
       " {'allow_none': True,\n",
       "  'default_args': None,\n",
       "  'default_kwargs': None,\n",
       "  'help': '',\n",
       "  'klass': jupyter_client.session.Session,\n",
       "  'metadata': {},\n",
       "  'name': 'session',\n",
       "  'this_class': ipykernel.datapub.ZMQDataPublisher},\n",
       " {'allow_none': True,\n",
       "  'help': '',\n",
       "  'metadata': {},\n",
       "  'name': 'pub_socket',\n",
       "  'this_class': ipykernel.datapub.ZMQDataPublisher},\n",
       " {'default_value': b'datapub',\n",
       "  'help': '',\n",
       "  'metadata': {},\n",
       "  'name': 'topic',\n",
       "  'this_class': ipykernel.datapub.ZMQDataPublisher},\n",
       " {'_traits': None,\n",
       "  'default_args': ({},),\n",
       "  'default_kwargs': None,\n",
       "  'help': '',\n",
       "  'klass': dict,\n",
       "  'metadata': {},\n",
       "  'name': 'parent_header',\n",
       "  'this_class': ipykernel.datapub.ZMQDataPublisher},\n",
       " deque([<_thread.lock at 0x7f51c009aa58>]),\n",
       " <function lock.release>,\n",
       " <function lock.acquire>,\n",
       " deque([]),\n",
       " <function lock.release>,\n",
       " <function lock.acquire>,\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'esc_strings': [],\n",
       "  'handler_name': 'normal',\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'_map': {<zmq.sugar.socket.Socket at 0x7f51c11eaca8>: 1,\n",
       "   29: 0,\n",
       "   <zmq.sugar.socket.Socket at 0x7f51c11ead68>: 2},\n",
       "  'sockets': [(29, 5),\n",
       "   (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 5),\n",
       "   (<zmq.sugar.socket.Socket at 0x7f51c11ead68>, 5)]},\n",
       " <cell at 0x7f51c1284b58: function object at 0x7f51c11f7598>,\n",
       " <cell at 0x7f51c1284b28: list object at 0x7f51c122b0c8>,\n",
       " <bound method ZMQStream._handle_events of <zmq.eventloop.zmqstream.ZMQStream object at 0x7f51c12216d8>>,\n",
       " [((), None)],\n",
       " <bound method ZMQStream._handle_events of <zmq.eventloop.zmqstream.ZMQStream object at 0x7f51c1221358>>,\n",
       " [((), None)],\n",
       " [],\n",
       " ({},),\n",
       " [],\n",
       " {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]},\n",
       " {<zmq.sugar.socket.Socket at 0x7f51c11eaca8>: 1,\n",
       "  29: 0,\n",
       "  <zmq.sugar.socket.Socket at 0x7f51c11ead68>: 2},\n",
       " [(29, 5),\n",
       "  (<zmq.sugar.socket.Socket at 0x7f51c11eaca8>, 5),\n",
       "  (<zmq.sugar.socket.Socket at 0x7f51c11ead68>, 5)],\n",
       " <function tornado.ioloop.PollIOLoop.initialize.<locals>.<lambda>>,\n",
       " [((), None)],\n",
       " [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>],\n",
       " (<cell at 0x7f51c1284af8: ZMQIOLoop object at 0x7f51c12214a8>,),\n",
       " <cell at 0x7f51c1284af8: ZMQIOLoop object at 0x7f51c12214a8>,\n",
       " <IPyAutocallChecker(priority=300, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 300,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 300,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <AssignmentChecker(priority=600, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 600,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 600,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [<weakref at 0x7f51c0052188; to 'sqlite3.Statement' at 0x7f51c00a5928>],\n",
       " [<weakref at 0x7f51c00bad18; dead>,\n",
       "  <weakref at 0x7f51c0052228; dead>,\n",
       "  <weakref at 0x7f51c0057278; dead>,\n",
       "  <weakref at 0x7f51c0057c28; dead>,\n",
       "  <weakref at 0x7f51c0052688; dead>,\n",
       "  <weakref at 0x7f51c0057638; dead>,\n",
       "  <weakref at 0x7f51c00524a8; dead>,\n",
       "  <weakref at 0x7f51c0057408; dead>,\n",
       "  <weakref at 0x7f51c0064868; dead>,\n",
       "  <weakref at 0x7f51c00ba9a8; dead>,\n",
       "  <weakref at 0x7f51c00ba818; dead>,\n",
       "  <weakref at 0x7f51c00ba688; dead>,\n",
       "  <weakref at 0x7f51c00ba638; dead>,\n",
       "  <weakref at 0x7f51c0073908; dead>,\n",
       "  <weakref at 0x7f51c0057368; dead>,\n",
       "  <weakref at 0x7f51c0064908; dead>,\n",
       "  <weakref at 0x7f51c00649a8; dead>,\n",
       "  <weakref at 0x7f51c00644f8; dead>,\n",
       "  <weakref at 0x7f51c0064638; dead>,\n",
       "  <weakref at 0x7f51c0064b38; dead>,\n",
       "  <weakref at 0x7f51c0064d18; dead>],\n",
       " <AutoMagicChecker(priority=700, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 700,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 700,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <PythonOpsChecker(priority=900, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 900,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 900,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <AutocallChecker(priority=1000, enabled=True)>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'enabled': True,\n",
       "   'exclude_regexp': re.compile(r'^[,&^\\|\\*/\\+-]|^is |^not |^in |^and |^or ',\n",
       "   re.UNICODE),\n",
       "   'function_name_regexp': re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$',\n",
       "   re.UNICODE),\n",
       "   'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "   'priority': 1000,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'enabled': True,\n",
       "  'exclude_regexp': re.compile(r'^[,&^\\|\\*/\\+-]|^is |^not |^in |^and |^or ',\n",
       "  re.UNICODE),\n",
       "  'function_name_regexp': re.compile(r'[a-zA-Z_]([a-zA-Z0-9_.]*) *$',\n",
       "  re.UNICODE),\n",
       "  'parent': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'prefilter_manager': <IPython.core.prefilter.PrefilterManager at 0x7f51c016e908>,\n",
       "  'priority': 1000,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " <bound method PrefilterManager.prefilter_lines of <IPython.core.prefilter.PrefilterManager object at 0x7f51c016e908>>,\n",
       " <function IPython.core.interactiveshell.InteractiveShell.init_syntax_highlighting.<locals>.<lambda>>,\n",
       " {'clipboard_get': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eeb8>,\n",
       "  'editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ecf8>,\n",
       "  'fix_error_editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed30>,\n",
       "  'late_startup_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016edd8>,\n",
       "  'pre_prompt_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee48>,\n",
       "  'pre_run_code_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee80>,\n",
       "  'show_in_pager': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee10>,\n",
       "  'shutdown_hook': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eda0>,\n",
       "  'synchronize_with_editor': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed68>},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ecf8>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.editor of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed30>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.fix_error_editor of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ed68>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.synchronize_with_editor of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eda0>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.shutdown_hook of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016edd8>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.late_startup_hook of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee10>,\n",
       " {'chain': [(99,\n",
       "    <bound method ZMQInteractiveShell.<lambda> of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>),\n",
       "   (100,\n",
       "    <bound method ZMQInteractiveShell.show_in_pager of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee48>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.pre_prompt_hook of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016ee80>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.pre_run_code_hook of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c016eeb8>,\n",
       " {'chain': [(100,\n",
       "    <bound method ZMQInteractiveShell.clipboard_get of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.events.EventManager at 0x7f51c016ecc0>,\n",
       " {'callbacks': {'post_execute': [],\n",
       "   'post_run_cell': [],\n",
       "   'pre_execute': [<bound method ZMQInteractiveShell._clear_warning_registry of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>],\n",
       "   'pre_run_cell': [],\n",
       "   'shell_initialized': []},\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " {'post_execute': [],\n",
       "  'post_run_cell': [],\n",
       "  'pre_execute': [<bound method ZMQInteractiveShell._clear_warning_registry of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>],\n",
       "  'pre_run_cell': [],\n",
       "  'shell_initialized': []},\n",
       " [],\n",
       " [<bound method ZMQInteractiveShell._clear_warning_registry of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>],\n",
       " [],\n",
       " [],\n",
       " <bound method ZMQInteractiveShell._clear_warning_registry of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       " [],\n",
       " ['',\n",
       "  'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "  \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "  'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "  'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "  'pick([1, 2, 3], 2)',\n",
       "  \"pick([1, 2, 3], '2')\",\n",
       "  'import gc',\n",
       "  'import gc\\nпс',\n",
       "  'import gc\\ngc',\n",
       "  'import gc\\ngc.garbage',\n",
       "  'gc.get_objects()'],\n",
       " ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       " <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       " <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       " {'_ip': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " {'In': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "  '_': [],\n",
       "  '_14': 3,\n",
       "  '_15': 3,\n",
       "  '_19': <module 'gc' (built-in)>,\n",
       "  '_20': [],\n",
       "  '__': <module 'gc' (built-in)>,\n",
       "  '___': 3,\n",
       "  '__builtin__': <module 'builtins' (built-in)>,\n",
       "  '__builtins__': <module 'builtins' (built-in)>,\n",
       "  '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "  '__loader__': None,\n",
       "  '__name__': '__main__',\n",
       "  '__package__': None,\n",
       "  '__spec__': None,\n",
       "  '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "  '_i': 'import gc\\ngc.garbage',\n",
       "  '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "  '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "  '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "  '_i15': 'pick([1, 2, 3], 2)',\n",
       "  '_i16': \"pick([1, 2, 3], '2')\",\n",
       "  '_i17': 'import gc',\n",
       "  '_i18': 'import gc\\nпс',\n",
       "  '_i19': 'import gc\\ngc',\n",
       "  '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "  '_i20': 'import gc\\ngc.garbage',\n",
       "  '_i21': 'gc.get_objects()',\n",
       "  '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "  '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "  '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "  '_ih': ['',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   'pick([1, 2, 3], 2)',\n",
       "   \"pick([1, 2, 3], '2')\",\n",
       "   'import gc',\n",
       "   'import gc\\nпс',\n",
       "   'import gc\\ngc',\n",
       "   'import gc\\ngc.garbage',\n",
       "   'gc.get_objects()'],\n",
       "  '_ii': 'import gc\\ngc',\n",
       "  '_iii': 'import gc\\nпс',\n",
       "  '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "  '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "  'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "  'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "  'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>},\n",
       " <IPython.core.logger.Logger at 0x7f51c016ef28>,\n",
       " <IPython.core.builtin_trap.BuiltinTrap at 0x7f51c016eef0>,\n",
       " {'_builtins_added': False,\n",
       "  '_cross_validation_lock': False,\n",
       "  '_nested_level': 1,\n",
       "  '_orig_builtins': {'dreload': <IPython.core.builtin_trap.__BuiltinUndefined at 0x7f51c5546860>,\n",
       "   'exit': Use exit() or Ctrl-D (i.e. EOF) to exit,\n",
       "   'get_ipython': <IPython.core.builtin_trap.__BuiltinUndefined at 0x7f51c5546860>,\n",
       "   'quit': Use quit() or Ctrl-D (i.e. EOF) to exit},\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {},\n",
       "   'parent': None,\n",
       "   'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       "  'auto_builtins': {'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'exit': <IPython.core.builtin_trap.__HideBuiltin at 0x7f51c5546898>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'quit': <IPython.core.builtin_trap.__HideBuiltin at 0x7f51c5546898>}},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " {'config': {},\n",
       "  'parent': None,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " {},\n",
       " {'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "  'exit': <IPython.core.builtin_trap.__HideBuiltin at 0x7f51c5546898>,\n",
       "  'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "  'quit': <IPython.core.builtin_trap.__HideBuiltin at 0x7f51c5546898>},\n",
       " <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       " <module 'IPython.lib.deepreload' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/lib/deepreload.py'>,\n",
       " {'ModuleType': module,\n",
       "  '__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/IPython/lib/__pycache__/deepreload.cpython-34.pyc',\n",
       "  '__doc__': \"\\nProvides a reload() function that acts recursively.\\n\\nPython's normal :func:`python:reload` function only reloads the module that it's\\npassed. The :func:`reload` function in this module also reloads everything\\nimported from that module, which is useful when you're changing files deep\\ninside a package.\\n\\nTo use this as your default reload function, type this for Python 2::\\n\\n    import __builtin__\\n    from IPython.lib import deepreload\\n    __builtin__.reload = deepreload.reload\\n\\nOr this for Python 3::\\n\\n    import builtins\\n    from IPython.lib import deepreload\\n    builtins.reload = deepreload.reload\\n\\nA reference to the original :func:`python:reload` is stored in this module as\\n:data:`original_reload`, so you can restore it later.\\n\\nThis code is almost entirely based on knee.py, which is a Python\\nre-implementation of hierarchical module import.\\n\",\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/IPython/lib/deepreload.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c0186160>,\n",
       "  '__name__': 'IPython.lib.deepreload',\n",
       "  '__package__': 'IPython.lib',\n",
       "  '__spec__': ModuleSpec(name='IPython.lib.deepreload', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c0186160>, origin='/home/pasha/.local/lib/python3.4/site-packages/IPython/lib/deepreload.py'),\n",
       "  '_dreload': <function IPython.lib.deepreload._dreload>,\n",
       "  'add_submodule': <function IPython.lib.deepreload.add_submodule>,\n",
       "  'builtin_mod': <module 'builtins' (built-in)>,\n",
       "  'builtin_mod_name': 'builtins',\n",
       "  'contextmanager': <function contextlib.contextmanager>,\n",
       "  'deep_import_hook': <function IPython.lib.deepreload.deep_import_hook>,\n",
       "  'deep_reload_hook': <function IPython.lib.deepreload.deep_reload_hook>,\n",
       "  'ensure_fromlist': <function IPython.lib.deepreload.ensure_fromlist>,\n",
       "  'found_now': {},\n",
       "  'get_parent': <function IPython.lib.deepreload.get_parent>,\n",
       "  'imp': <module 'imp' from '/usr/lib64/python3.4/imp.py'>,\n",
       "  'import_submodule': <function IPython.lib.deepreload.import_submodule>,\n",
       "  'load_next': <function IPython.lib.deepreload.load_next>,\n",
       "  'modules_reloading': {},\n",
       "  'original_import': <function __import__>,\n",
       "  'original_reload': <function imp.reload>,\n",
       "  'print_function': _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536),\n",
       "  'reload': <function IPython.lib.deepreload.reload>,\n",
       "  'replace_import_hook': <function IPython.lib.deepreload.replace_import_hook>,\n",
       "  'sys': <module 'sys' (built-in)>,\n",
       "  'warn': <function _warnings.warn>},\n",
       " (\"\\n    parent, name = get_parent(globals, level)\\n\\n    Return the package that an import is being performed in.  If globals comes\\n    from the module foo.bar.bat (not itself a package), this returns the\\n    sys.modules entry for foo.bar.  If globals is from a package's __init__.py,\\n    the package's entry in sys.modules is returned.\\n\\n    If globals doesn't come from a package or a module in a package, or a\\n    corresponding entry is not found in sys.modules, None is returned.\\n    \",\n",
       "  None,\n",
       "  '',\n",
       "  '__package__',\n",
       "  'rindex',\n",
       "  '__package__ set to non-string',\n",
       "  0,\n",
       "  'Attempted relative import in non-package',\n",
       "  '__name__',\n",
       "  '__path__',\n",
       "  '.',\n",
       "  1,\n",
       "  'attempted relative import beyond top-level package',\n",
       "  \"Parent module '%.200s' not found while handling absolute import\",\n",
       "  \"Parent module '%.200s' not loaded, cannot perform relative import\",\n",
       "  (None, ''),\n",
       "  (None, ''),\n",
       "  (None, ''),\n",
       "  (None, ''),\n",
       "  -1),\n",
       " <function IPython.lib.deepreload.replace_import_hook>,\n",
       " {'__wrapped__': <function IPython.lib.deepreload.replace_import_hook>},\n",
       " <function IPython.lib.deepreload.get_parent>,\n",
       " <function IPython.lib.deepreload.load_next>,\n",
       " <function IPython.lib.deepreload.import_submodule>,\n",
       " <function IPython.lib.deepreload.add_submodule>,\n",
       " <function IPython.lib.deepreload.ensure_fromlist>,\n",
       " <function IPython.lib.deepreload.deep_import_hook>,\n",
       " <function IPython.lib.deepreload.deep_reload_hook>,\n",
       " <function IPython.lib.deepreload.reload>,\n",
       " (('sys', 'os.path', 'builtins', '__main__'),),\n",
       " <function IPython.lib.deepreload._dreload>,\n",
       " <IPython.core.oinspect.Inspector at 0x7f51c016ef60>,\n",
       " {'color_table': {'': <IPython.utils.coloransi.ColorScheme at 0x7f51c72739e8>,\n",
       "   'LightBG': <IPython.utils.coloransi.ColorScheme at 0x7f51c7273a20>,\n",
       "   'Linux': <IPython.utils.coloransi.ColorScheme at 0x7f51c72739e8>,\n",
       "   'NoColor': <IPython.utils.coloransi.ColorScheme at 0x7f51c7273978>},\n",
       "  'format': <bound method Parser.format of <IPython.utils.PyColorize.Parser object at 0x7f51c016efd0>>,\n",
       "  'parser': <IPython.utils.PyColorize.Parser at 0x7f51c016efd0>,\n",
       "  'str_detail_level': 0},\n",
       " <IPython.utils.PyColorize.Parser at 0x7f51c016efd0>,\n",
       " {'color_table': {'': <IPython.utils.coloransi.ColorScheme at 0x7f51c72739e8>,\n",
       "   'LightBG': <IPython.utils.coloransi.ColorScheme at 0x7f51c7273a20>,\n",
       "   'Linux': <IPython.utils.coloransi.ColorScheme at 0x7f51c72739e8>,\n",
       "   'NoColor': <IPython.utils.coloransi.ColorScheme at 0x7f51c7273978>},\n",
       "  'out': 'str'},\n",
       " <bound method Parser.format of <IPython.utils.PyColorize.Parser object at 0x7f51c016efd0>>,\n",
       " <IPython.utils.contexts.NoOpContext at 0x7f51c0186048>,\n",
       " <module 'IPython.core.completerlib' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/completerlib.py'>,\n",
       " {'TIMEOUT_GIVEUP': 20,\n",
       "  'TIMEOUT_STORAGE': 2,\n",
       "  'TryNext': IPython.core.error.TryNext,\n",
       "  '__builtins__': {'ArithmeticError': ArithmeticError,\n",
       "   'AssertionError': AssertionError,\n",
       "   'AttributeError': AttributeError,\n",
       "   'BaseException': BaseException,\n",
       "   'BlockingIOError': BlockingIOError,\n",
       "   'BrokenPipeError': BrokenPipeError,\n",
       "   'BufferError': BufferError,\n",
       "   'BytesWarning': BytesWarning,\n",
       "   'ChildProcessError': ChildProcessError,\n",
       "   'ConnectionAbortedError': ConnectionAbortedError,\n",
       "   'ConnectionError': ConnectionError,\n",
       "   'ConnectionRefusedError': ConnectionRefusedError,\n",
       "   'ConnectionResetError': ConnectionResetError,\n",
       "   'DeprecationWarning': DeprecationWarning,\n",
       "   'EOFError': EOFError,\n",
       "   'Ellipsis': Ellipsis,\n",
       "   'EnvironmentError': OSError,\n",
       "   'Exception': Exception,\n",
       "   'False': False,\n",
       "   'FileExistsError': FileExistsError,\n",
       "   'FileNotFoundError': FileNotFoundError,\n",
       "   'FloatingPointError': FloatingPointError,\n",
       "   'FutureWarning': FutureWarning,\n",
       "   'GeneratorExit': GeneratorExit,\n",
       "   'IOError': OSError,\n",
       "   'ImportError': ImportError,\n",
       "   'ImportWarning': ImportWarning,\n",
       "   'IndentationError': IndentationError,\n",
       "   'IndexError': IndexError,\n",
       "   'InterruptedError': InterruptedError,\n",
       "   'IsADirectoryError': IsADirectoryError,\n",
       "   'KeyError': KeyError,\n",
       "   'KeyboardInterrupt': KeyboardInterrupt,\n",
       "   'LookupError': LookupError,\n",
       "   'MemoryError': MemoryError,\n",
       "   'NameError': NameError,\n",
       "   'None': None,\n",
       "   'NotADirectoryError': NotADirectoryError,\n",
       "   'NotImplemented': NotImplemented,\n",
       "   'NotImplementedError': NotImplementedError,\n",
       "   'OSError': OSError,\n",
       "   'OverflowError': OverflowError,\n",
       "   'PendingDeprecationWarning': PendingDeprecationWarning,\n",
       "   'PermissionError': PermissionError,\n",
       "   'ProcessLookupError': ProcessLookupError,\n",
       "   'ReferenceError': ReferenceError,\n",
       "   'ResourceWarning': ResourceWarning,\n",
       "   'RuntimeError': RuntimeError,\n",
       "   'RuntimeWarning': RuntimeWarning,\n",
       "   'StopIteration': StopIteration,\n",
       "   'SyntaxError': SyntaxError,\n",
       "   'SyntaxWarning': SyntaxWarning,\n",
       "   'SystemError': SystemError,\n",
       "   'SystemExit': SystemExit,\n",
       "   'TabError': TabError,\n",
       "   'TimeoutError': TimeoutError,\n",
       "   'True': True,\n",
       "   'TypeError': TypeError,\n",
       "   'UnboundLocalError': UnboundLocalError,\n",
       "   'UnicodeDecodeError': UnicodeDecodeError,\n",
       "   'UnicodeEncodeError': UnicodeEncodeError,\n",
       "   'UnicodeError': UnicodeError,\n",
       "   'UnicodeTranslateError': UnicodeTranslateError,\n",
       "   'UnicodeWarning': UnicodeWarning,\n",
       "   'UserWarning': UserWarning,\n",
       "   'ValueError': ValueError,\n",
       "   'Warning': Warning,\n",
       "   'ZeroDivisionError': ZeroDivisionError,\n",
       "   '__IPYTHON__': True,\n",
       "   '__IPYTHON__active': 'Deprecated, check for __IPYTHON__',\n",
       "   '__build_class__': <function __build_class__>,\n",
       "   '__debug__': True,\n",
       "   '__doc__': \"Built-in functions, exceptions, and other objects.\\n\\nNoteworthy: None is the `nil' object; Ellipsis represents `...' in slices.\",\n",
       "   '__import__': <function __import__>,\n",
       "   '__loader__': _frozen_importlib.BuiltinImporter,\n",
       "   '__name__': 'builtins',\n",
       "   '__package__': '',\n",
       "   '__spec__': ModuleSpec(name='builtins', loader=<class '_frozen_importlib.BuiltinImporter'>),\n",
       "   'abs': <function abs>,\n",
       "   'all': <function all>,\n",
       "   'any': <function any>,\n",
       "   'ascii': <function ascii>,\n",
       "   'bin': <function bin>,\n",
       "   'bool': bool,\n",
       "   'bytearray': bytearray,\n",
       "   'bytes': bytes,\n",
       "   'callable': <function callable>,\n",
       "   'chr': <function chr>,\n",
       "   'classmethod': classmethod,\n",
       "   'compile': <function compile>,\n",
       "   'complex': complex,\n",
       "   'copyright': Copyright (c) 2001-2015 Python Software Foundation.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 2000 BeOpen.com.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1995-2001 Corporation for National Research Initiatives.\n",
       "   All Rights Reserved.\n",
       "   \n",
       "   Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.\n",
       "   All Rights Reserved.,\n",
       "   'credits':     Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands\n",
       "       for supporting Python development.  See www.python.org for more information.,\n",
       "   'delattr': <function delattr>,\n",
       "   'dict': dict,\n",
       "   'dir': <function dir>,\n",
       "   'divmod': <function divmod>,\n",
       "   'dreload': <function IPython.lib.deepreload._dreload>,\n",
       "   'enumerate': enumerate,\n",
       "   'eval': <function eval>,\n",
       "   'exec': <function exec>,\n",
       "   'filter': filter,\n",
       "   'float': float,\n",
       "   'format': <function format>,\n",
       "   'frozenset': frozenset,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'getattr': <function getattr>,\n",
       "   'globals': <function globals>,\n",
       "   'hasattr': <function hasattr>,\n",
       "   'hash': <function hash>,\n",
       "   'help': Type help() for interactive help, or help(object) for help about object.,\n",
       "   'hex': <function hex>,\n",
       "   'id': <function id>,\n",
       "   'input': <bound method IPythonKernel.raw_input of <ipykernel.ipkernel.IPythonKernel object at 0x7f51c1221278>>,\n",
       "   'int': int,\n",
       "   'isinstance': <function isinstance>,\n",
       "   'issubclass': <function issubclass>,\n",
       "   'iter': <function iter>,\n",
       "   'len': <function len>,\n",
       "   'license': See https://www.python.org/psf/license/,\n",
       "   'list': list,\n",
       "   'locals': <function locals>,\n",
       "   'map': map,\n",
       "   'max': <function max>,\n",
       "   'memoryview': memoryview,\n",
       "   'min': <function min>,\n",
       "   'next': <function next>,\n",
       "   'object': object,\n",
       "   'oct': <function oct>,\n",
       "   'open': <function io.open>,\n",
       "   'ord': <function ord>,\n",
       "   'pow': <function pow>,\n",
       "   'print': <function print>,\n",
       "   'property': property,\n",
       "   'range': range,\n",
       "   'repr': <function repr>,\n",
       "   'reversed': reversed,\n",
       "   'round': <function round>,\n",
       "   'set': set,\n",
       "   'setattr': <function setattr>,\n",
       "   'slice': slice,\n",
       "   'sorted': <function sorted>,\n",
       "   'staticmethod': staticmethod,\n",
       "   'str': str,\n",
       "   'sum': <function sum>,\n",
       "   'super': super,\n",
       "   'tuple': tuple,\n",
       "   'type': type,\n",
       "   'vars': <function vars>,\n",
       "   'zip': zip},\n",
       "  '__cached__': '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/__pycache__/completerlib.cpython-34.pyc',\n",
       "  '__doc__': 'Implementations for various useful completers.\\n\\nThese are all loaded by default by IPython.\\n',\n",
       "  '__file__': '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/completerlib.py',\n",
       "  '__loader__': <_frozen_importlib.SourceFileLoader at 0x7f51c0186470>,\n",
       "  '__name__': 'IPython.core.completerlib',\n",
       "  '__package__': 'IPython.core',\n",
       "  '__spec__': ModuleSpec(name='IPython.core.completerlib', loader=<_frozen_importlib.SourceFileLoader object at 0x7f51c0186470>, origin='/home/pasha/.local/lib/python3.4/site-packages/IPython/core/completerlib.py'),\n",
       "  '_suffixes': ['.py', '.pyc', '.cpython-34m.so', '.abi3.so', '.so'],\n",
       "  'all_suffixes': <function importlib.machinery.all_suffixes>,\n",
       "  'arg_split': <function IPython.utils._process_common.arg_split>,\n",
       "  'cd_completer': <function IPython.core.completerlib.cd_completer>,\n",
       "  'compress_user': <function IPython.core.completer.compress_user>,\n",
       "  'expand_user': <function IPython.core.completer.expand_user>,\n",
       "  'get_ipython': <function IPython.core.getipython.get_ipython>,\n",
       "  'get_root_modules': <function IPython.core.completerlib.get_root_modules>,\n",
       "  'glob': <module 'glob' from '/usr/lib64/python3.4/glob.py'>,\n",
       "  'import_re': re.compile(r'(?P<name>[a-zA-Z_][a-zA-Z0-9_]*?)(?P<package>[/\\\\]__init__)?(?P<suffix>\\.py|\\.pyc|\\.cpython\\-34m\\.so|\\.abi3\\.so|\\.so)$',\n",
       "  re.UNICODE),\n",
       "  'inspect': <module 'inspect' from '/usr/lib64/python3.4/inspect.py'>,\n",
       "  'is_importable': <function IPython.core.completerlib.is_importable>,\n",
       "  'magic_run_completer': <function IPython.core.completerlib.magic_run_completer>,\n",
       "  'magic_run_re': re.compile(r'.*(\\.ipy|\\.ipynb|\\.py[w]?)$', re.UNICODE),\n",
       "  'module_completer': <function IPython.core.completerlib.module_completer>,\n",
       "  'module_completion': <function IPython.core.completerlib.module_completion>,\n",
       "  'module_list': <function IPython.core.completerlib.module_list>,\n",
       "  'os': <module 'os' from '/usr/lib64/python3.4/os.py'>,\n",
       "  'print_function': _Feature((2, 6, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 65536),\n",
       "  'quick_completer': <function IPython.core.completerlib.quick_completer>,\n",
       "  're': <module 're' from '/usr/lib64/python3.4/re.py'>,\n",
       "  'reset_completer': <function IPython.core.completerlib.reset_completer>,\n",
       "  'string_types': (str,),\n",
       "  'sys': <module 'sys' (built-in)>,\n",
       "  'time': <function time.time>,\n",
       "  'try_import': <function IPython.core.completerlib.try_import>,\n",
       "  'zipimporter': zipimport.zipimporter},\n",
       " (\"\\n    Returns a list containing the names of all the modules available in the\\n    folders of the pythonpath.\\n\\n    ip.db['rootmodules_cache'] maps sys.path entries to list of modules.\\n    \",\n",
       "  'rootmodules_cache',\n",
       "  False,\n",
       "  '__init__',\n",
       "  '',\n",
       "  '.',\n",
       "  True,\n",
       "  '\\nCaching the list of root modules, please wait!',\n",
       "  \"(This will only be done once - type '%rehashx' to reset cache!)\\n\",\n",
       "  'This is taking too long, we give up.\\n',\n",
       "  ('', '.')),\n",
       " (\"\\n    Returns a list containing the completion possibilities for an import line.\\n\\n    The line looks like this :\\n    'import xml.d'\\n    'from xml.dom import'\\n    \",\n",
       "  ' ',\n",
       "  3,\n",
       "  0,\n",
       "  'from',\n",
       "  'import ',\n",
       "  '%aimport',\n",
       "  'import',\n",
       "  1,\n",
       "  '.',\n",
       "  2,\n",
       "  None,\n",
       "  True,\n",
       "  <code object <listcomp> at 0x7f51c0189810, file \"/home/pasha/.local/lib/python3.4/site-packages/IPython/core/completerlib.py\", line 233>,\n",
       "  'module_completion.<locals>.<listcomp>',\n",
       "  frozenset({'%aimport', 'from', 'import'}),\n",
       "  -1),\n",
       " frozenset({'%aimport', 'from', 'import'}),\n",
       " ['.py', '.pyc', '.cpython-34m.so', '.abi3.so', '.so'],\n",
       " [None, 'name', 'package', 'suffix'],\n",
       " [None, None],\n",
       " <function IPython.core.completerlib.module_list>,\n",
       " <function IPython.core.completerlib.get_root_modules>,\n",
       " <function IPython.core.completerlib.is_importable>,\n",
       " <function IPython.core.completerlib.try_import>,\n",
       " <function IPython.core.completerlib.quick_completer>,\n",
       " <function IPython.core.completerlib.module_completion>,\n",
       " <function IPython.core.completerlib.module_completer>,\n",
       " <function IPython.core.completerlib.magic_run_completer>,\n",
       " <function IPython.core.completerlib.cd_completer>,\n",
       " <function IPython.core.completerlib.reset_completer>,\n",
       " <IPython.core.completer.IPCompleter at 0x7f51c0186080>,\n",
       " {'_cross_validation_lock': False,\n",
       "  '_trait_notifiers': {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       "  '_trait_validators': {},\n",
       "  '_trait_values': {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "   'greedy': False,\n",
       "   'limit_to__all__': False,\n",
       "   'merge_completions': True,\n",
       "   'omit__names': 2,\n",
       "   'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       "  'clean_glob': <bound method IPCompleter._clean_glob of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "  'custom_completers': <Strdispatch {'%run': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186fd0>, 'from': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e80>, '%reset': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c01863c8>, '%aimport': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186f28>, 'import': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e48>, '%cd': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186358>}, {}>,\n",
       "  'docstring_kwd_re': re.compile(r'[\\s|\\[]*(\\w+)(?:\\s*=\\s*.*)', re.UNICODE),\n",
       "  'docstring_sig_re': re.compile(r'^[\\w|\\s.]+\\(([^)]*)\\).*', re.UNICODE),\n",
       "  'dumb_terminal': False,\n",
       "  'glob': <function glob.glob>,\n",
       "  'global_namespace': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}},\n",
       "  'magic_escape': '%',\n",
       "  'matchers': [<bound method IPCompleter.python_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "   <bound method IPCompleter.file_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "   <bound method IPCompleter.magic_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "   <bound method IPCompleter.python_func_kw_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "   <bound method IPCompleter.dict_key_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>],\n",
       "  'matches': [],\n",
       "  'namespace': {'In': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   'Out': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_': [],\n",
       "   '_14': 3,\n",
       "   '_15': 3,\n",
       "   '_19': <module 'gc' (built-in)>,\n",
       "   '_20': [],\n",
       "   '__': <module 'gc' (built-in)>,\n",
       "   '___': 3,\n",
       "   '__builtin__': <module 'builtins' (built-in)>,\n",
       "   '__builtins__': <module 'builtins' (built-in)>,\n",
       "   '__doc__': 'Automatically created module for IPython interactive environment',\n",
       "   '__loader__': None,\n",
       "   '__name__': '__main__',\n",
       "   '__package__': None,\n",
       "   '__spec__': None,\n",
       "   '_dh': ['/home/pasha/machine-learning.coursera/LearnInProgress/final.assignment/Kaggle'],\n",
       "   '_i': 'import gc\\ngc.garbage',\n",
       "   '_i1': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i10': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i11': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i12': 'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "   '_i13': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "   '_i14': 'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "   '_i15': 'pick([1, 2, 3], 2)',\n",
       "   '_i16': \"pick([1, 2, 3], '2')\",\n",
       "   '_i17': 'import gc',\n",
       "   '_i18': 'import gc\\nпс',\n",
       "   '_i19': 'import gc\\ngc',\n",
       "   '_i2': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "   '_i20': 'import gc\\ngc.garbage',\n",
       "   '_i21': 'gc.get_objects()',\n",
       "   '_i3': 'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "   '_i4': \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i5': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "   '_i6': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i7': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i8': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_i9': \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "   '_ih': ['',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print x[v]\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception, e:\\n        print e\\n        pass',\n",
       "    'x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print e\\n        pass',\n",
       "    \"x = {1: False, 2: True} # no 3\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('\\\\tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...tcontinue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n#        pass\",\n",
       "    \"x = {1: False, 3: True} # no 2!\\n\\nfor v in [1,2,3]:\\n    try:\\n        print (x[v])\\n        print ('...continue')\\n    except Exception as e:\\n        print ('Exception happened', e)\\n        pass\",\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3])',\n",
       "    'def pick(l: list, index: int) -> int:\\n    return l[index]\\n\\npick([1, 2, 3], 2)',\n",
       "    'pick([1, 2, 3], 2)',\n",
       "    \"pick([1, 2, 3], '2')\",\n",
       "    'import gc',\n",
       "    'import gc\\nпс',\n",
       "    'import gc\\ngc',\n",
       "    'import gc\\ngc.garbage',\n",
       "    'gc.get_objects()'],\n",
       "   '_ii': 'import gc\\ngc',\n",
       "   '_iii': 'import gc\\nпс',\n",
       "   '_oh': {14: 3, 15: 3, 19: <module 'gc' (built-in)>, 20: []},\n",
       "   '_sh': <module 'IPython.core.shadowns' from '/home/pasha/.local/lib/python3.4/site-packages/IPython/core/shadowns.py'>,\n",
       "   'exit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'gc': <module 'gc' (built-in)>,\n",
       "   'get_ipython': <bound method ZMQInteractiveShell.get_ipython of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>,\n",
       "   'pick': <function __main__.pick>,\n",
       "   'quit': <IPython.core.autocall.ZMQExitAutocall at 0x7f51c016ef98>,\n",
       "   'v': 3,\n",
       "   'x': {1: False, 3: True}},\n",
       "  'readline': None,\n",
       "  'shell': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>,\n",
       "  'space_name_re': re.compile(r'([^\\\\] )', re.UNICODE),\n",
       "  'splitter': <IPython.core.completer.CompletionSplitter at 0x7f51c01860b8>,\n",
       "  'use_main_ns': 0},\n",
       " {'config': {'change': [<traitlets.traitlets.ObserveHandler at 0x7f51c93fca58>]}},\n",
       " <IPython.core.completer.CompletionSplitter at 0x7f51c01860b8>,\n",
       " [None],\n",
       " {'config': {'IPKernelApp': {'connection_file': '/home/pasha/.local/share/jupyter/runtime/kernel-5f9aca5a-28c1-45e8-a46e-1a30a486cf58.json'}},\n",
       "  'greedy': False,\n",
       "  'limit_to__all__': False,\n",
       "  'merge_completions': True,\n",
       "  'omit__names': 2,\n",
       "  'parent': <ipykernel.zmqshell.ZMQInteractiveShell at 0x7f51c12210b8>},\n",
       " [],\n",
       " [None, None],\n",
       " <bound method IPCompleter._clean_glob of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       " [None, None],\n",
       " [None, None],\n",
       " [<bound method IPCompleter.python_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "  <bound method IPCompleter.file_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "  <bound method IPCompleter.magic_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "  <bound method IPCompleter.python_func_kw_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>,\n",
       "  <bound method IPCompleter.dict_key_matches of <IPython.core.completer.IPCompleter object at 0x7f51c0186080>>],\n",
       " <Strdispatch {'%run': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186fd0>, 'from': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e80>, '%reset': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c01863c8>, '%aimport': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186f28>, 'import': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e48>, '%cd': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186358>}, {}>,\n",
       " {'regexs': {},\n",
       "  'strs': {'%aimport': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186f28>,\n",
       "   '%cd': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186358>,\n",
       "   '%reset': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c01863c8>,\n",
       "   '%run': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186fd0>,\n",
       "   'from': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186e80>,\n",
       "   'import': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186e48>}},\n",
       " {'complete_command': <Strdispatch {'%run': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186fd0>, 'from': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e80>, '%reset': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c01863c8>, '%aimport': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186f28>, 'import': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186e48>, '%cd': <IPython.core.hooks.CommandChainDispatcher object at 0x7f51c0186358>}, {}>},\n",
       " {'%aimport': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186f28>,\n",
       "  '%cd': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186358>,\n",
       "  '%reset': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c01863c8>,\n",
       "  '%run': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186fd0>,\n",
       "  'from': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186e80>,\n",
       "  'import': <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186e48>},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186e80>,\n",
       " {'chain': [(50,\n",
       "    <bound method ZMQInteractiveShell.module_completer of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186f28>,\n",
       " {'chain': [(50,\n",
       "    <bound method ZMQInteractiveShell.module_completer of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186fd0>,\n",
       " {'chain': [(50,\n",
       "    <bound method ZMQInteractiveShell.magic_run_completer of <ipykernel.zmqshell.ZMQInteractiveShell object at 0x7f51c12210b8>>)]},\n",
       " <IPython.core.hooks.CommandChainDispatcher at 0x7f51c0186358>,\n",
       " ...]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gc.get_objects()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# %magic\n",
    "\n",
    "https://ipython.org/ipython-doc/3/interactive/magics.html"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/json": {
       "cell": {
        "!": "OSMagics",
        "HTML": "Other",
        "SVG": "Other",
        "bash": "Other",
        "capture": "ExecutionMagics",
        "debug": "ExecutionMagics",
        "file": "Other",
        "html": "DisplayMagics",
        "javascript": "DisplayMagics",
        "latex": "DisplayMagics",
        "perl": "Other",
        "prun": "ExecutionMagics",
        "pypy": "Other",
        "python": "Other",
        "python2": "Other",
        "python3": "Other",
        "ruby": "Other",
        "script": "ScriptMagics",
        "sh": "Other",
        "svg": "DisplayMagics",
        "sx": "OSMagics",
        "system": "OSMagics",
        "time": "ExecutionMagics",
        "timeit": "ExecutionMagics",
        "writefile": "OSMagics"
       },
       "line": {
        "alias": "OSMagics",
        "alias_magic": "BasicMagics",
        "autocall": "AutoMagics",
        "automagic": "AutoMagics",
        "autosave": "KernelMagics",
        "bookmark": "OSMagics",
        "cat": "Other",
        "cd": "OSMagics",
        "clear": "KernelMagics",
        "colors": "BasicMagics",
        "config": "ConfigMagics",
        "connect_info": "KernelMagics",
        "cp": "Other",
        "debug": "ExecutionMagics",
        "dhist": "OSMagics",
        "dirs": "OSMagics",
        "doctest_mode": "BasicMagics",
        "ed": "Other",
        "edit": "KernelMagics",
        "env": "OSMagics",
        "gui": "BasicMagics",
        "hist": "Other",
        "history": "HistoryMagics",
        "install_default_config": "DeprecatedMagics",
        "install_ext": "ExtensionMagics",
        "install_profiles": "DeprecatedMagics",
        "killbgscripts": "ScriptMagics",
        "ldir": "Other",
        "less": "KernelMagics",
        "lf": "Other",
        "lk": "Other",
        "ll": "Other",
        "load": "CodeMagics",
        "load_ext": "ExtensionMagics",
        "loadpy": "CodeMagics",
        "logoff": "LoggingMagics",
        "logon": "LoggingMagics",
        "logstart": "LoggingMagics",
        "logstate": "LoggingMagics",
        "logstop": "LoggingMagics",
        "ls": "Other",
        "lsmagic": "BasicMagics",
        "lx": "Other",
        "macro": "ExecutionMagics",
        "magic": "BasicMagics",
        "man": "KernelMagics",
        "matplotlib": "PylabMagics",
        "mkdir": "Other",
        "more": "KernelMagics",
        "mv": "Other",
        "notebook": "BasicMagics",
        "page": "BasicMagics",
        "pastebin": "CodeMagics",
        "pdb": "ExecutionMagics",
        "pdef": "NamespaceMagics",
        "pdoc": "NamespaceMagics",
        "pfile": "NamespaceMagics",
        "pinfo": "NamespaceMagics",
        "pinfo2": "NamespaceMagics",
        "popd": "OSMagics",
        "pprint": "BasicMagics",
        "precision": "BasicMagics",
        "profile": "BasicMagics",
        "prun": "ExecutionMagics",
        "psearch": "NamespaceMagics",
        "psource": "NamespaceMagics",
        "pushd": "OSMagics",
        "pwd": "OSMagics",
        "pycat": "OSMagics",
        "pylab": "PylabMagics",
        "qtconsole": "KernelMagics",
        "quickref": "BasicMagics",
        "recall": "HistoryMagics",
        "rehashx": "OSMagics",
        "reload_ext": "ExtensionMagics",
        "rep": "Other",
        "rerun": "HistoryMagics",
        "reset": "NamespaceMagics",
        "reset_selective": "NamespaceMagics",
        "rm": "Other",
        "rmdir": "Other",
        "run": "ExecutionMagics",
        "save": "CodeMagics",
        "sc": "OSMagics",
        "set_env": "OSMagics",
        "store": "StoreMagics",
        "sx": "OSMagics",
        "system": "OSMagics",
        "tb": "ExecutionMagics",
        "time": "ExecutionMagics",
        "timeit": "ExecutionMagics",
        "unalias": "OSMagics",
        "unload_ext": "ExtensionMagics",
        "who": "NamespaceMagics",
        "who_ls": "NamespaceMagics",
        "whos": "NamespaceMagics",
        "xdel": "NamespaceMagics",
        "xmode": "BasicMagics"
       }
      },
      "text/plain": [
       "Available line magics:\n",
       "%alias  %alias_magic  %autocall  %automagic  %autosave  %bookmark  %cat  %cd  %clear  %colors  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %install_default_config  %install_ext  %install_profiles  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %man  %matplotlib  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %rmdir  %run  %save  %sc  %set_env  %store  %sx  %system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode\n",
       "\n",
       "Available cell magics:\n",
       "%%!  %%HTML  %%SVG  %%bash  %%capture  %%debug  %%file  %%html  %%javascript  %%latex  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile\n",
       "\n",
       "Automagic is ON, % prefix IS NOT needed for line magics."
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%lsmagic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%magic"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The slowest run took 19.35 times longer than the fastest. This could mean that an intermediate result is being cached.\n",
      "1000000 loops, best of 3: 660 ns per loop\n"
     ]
    }
   ],
   "source": [
    "%timeit range(1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n",
      "Wall time: 761 µs\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "range(0, 1000)"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "%time range(1000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%pinfo x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%pinfo2 x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pretty printing has been turned ON\n"
     ]
    }
   ],
   "source": [
    "%pprint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " "
     ]
    }
   ],
   "source": [
    "%prun range(1000)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "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.7.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": "block",
   "toc_window_display": true
  },
  "toc_position": {
   "height": "400px",
   "left": "1274px",
   "right": "20px",
   "top": "120px",
   "width": "265px"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}