"evalue": "invalid syntax (<ipython-input-12-d15a1049ba44>, line 1)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-12-d15a1049ba44>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m C. Within Your Program\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"C. Within Your Program"
"**C. Within Your Program**"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "Missing parentheses in call to 'print'. Did you mean print(i)? (<ipython-input-13-16ddb2fede32>, line 15)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-13-16ddb2fede32>\"\u001b[1;36m, line \u001b[1;32m15\u001b[0m\n\u001b[1;33m print i\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m Missing parentheses in call to 'print'. Did you mean print(i)?\n"
"name": "stdout",
"output_type": "stream",
"text": [
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) p i\n",
"0\n",
"(Pdb) c\n",
"0\n",
"> <ipython-input-4-91e9c298fd93>(13)go()\n",
"-> pdb.set_trace()\n",
"(Pdb) c\n",
"1\n",
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) c\n",
"2\n",
"> <ipython-input-4-91e9c298fd93>(13)go()\n",
"-> pdb.set_trace()\n",
"(Pdb) c\n",
"3\n",
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) c\n",
"4\n"
]
}
],
...
...
@@ -246,14 +274,13 @@
"import pdb\n",
"\n",
"class MyObj(object):\n",
" count = 5\n",
" def __init__(self):\n",
" self.count= 9\n",
" def __init__(self,count):\n",
" self.count= count\n",
"\n",
" def go(self):\n",
" for i in range(self.count):\n",
" pdb.set_trace()\n",
" print i\n",
" print(i)\n",
" return\n",
"\n",
"if __name__ == '__main__':\n",
...
...
@@ -264,16 +291,55 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### PyCharm\n",
"**D.With Cell Magic in Jupyter Notebook**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NOTE: Enter 'c' at the ipdb> prompt to continue execution.\n",
"\u001b[0;31mTypeError\u001b[0m: must be str, not int\n"
]
}
],
"source": [
"%%debug \n",
"\n",
"Go to: ./examplepydebuggingandtesting/examplepydebuggingandtesting/example.py"
"a=4\n",
"b=\"4\"\n",
"if 8 == b + a:\n",
" print(\"sucess!\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## (Interpret errors)"
"### PyCharm\n",
"\n",
"Go to: ./examplepydebuggingandtesting/examplepydebuggingandtesting/example.py"
]
},
{
...
...
@@ -293,10 +359,8 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"## hooks for unittests (or use a continuous-integration server)\n",
"\n",
...
...
@@ -304,24 +368,20 @@
]
},
{
"cell_type": "code",
"execution_count": 2,
"cell_type": "markdown",
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "invalid syntax (<ipython-input-2-23f75e5e4fc4>, line 3)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-2-23f75e5e4fc4>\"\u001b[1;36m, line \u001b[1;32m3\u001b[0m\n\u001b[1;33m use test runner to explore results\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
"evalue": "invalid syntax (<ipython-input-12-d15a1049ba44>, line 1)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-12-d15a1049ba44>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m C. Within Your Program\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
]
}
],
"source": [
"C. Within Your Program"
"**C. Within Your Program**"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "SyntaxError",
"evalue": "Missing parentheses in call to 'print'. Did you mean print(i)? (<ipython-input-13-16ddb2fede32>, line 15)",
"output_type": "error",
"traceback": [
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-13-16ddb2fede32>\"\u001b[1;36m, line \u001b[1;32m15\u001b[0m\n\u001b[1;33m print i\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m Missing parentheses in call to 'print'. Did you mean print(i)?\n"
"name": "stdout",
"output_type": "stream",
"text": [
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) p i\n",
"0\n",
"(Pdb) c\n",
"0\n",
"> <ipython-input-4-91e9c298fd93>(13)go()\n",
"-> pdb.set_trace()\n",
"(Pdb) c\n",
"1\n",
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) c\n",
"2\n",
"> <ipython-input-4-91e9c298fd93>(13)go()\n",
"-> pdb.set_trace()\n",
"(Pdb) c\n",
"3\n",
"> <ipython-input-4-91e9c298fd93>(14)go()\n",
"-> print(i)\n",
"(Pdb) c\n",
"4\n"
]
}
],
...
...
@@ -246,14 +274,13 @@
"import pdb\n",
"\n",
"class MyObj(object):\n",
" count = 5\n",
" def __init__(self):\n",
" self.count= 9\n",
" def __init__(self,count):\n",
" self.count= count\n",
"\n",
" def go(self):\n",
" for i in range(self.count):\n",
" pdb.set_trace()\n",
" print i\n",
" print(i)\n",
" return\n",
"\n",
"if __name__ == '__main__':\n",
...
...
@@ -264,16 +291,55 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"### PyCharm\n",
"**D.With Cell Magic in Jupyter Notebook**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"NOTE: Enter 'c' at the ipdb> prompt to continue execution.\n",