Created
June 18, 2014 06:10
-
-
Save schodge/72cf87699ca61bdc72dd to your computer and use it in GitHub Desktop.
Notebook to replicate pdb error
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:d8442894ec852c8db8eec43105ae76977035530d3060058e25119cebae2a7a39" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [ | |
"%pdb on\n", | |
"import numpy as np\n", | |
"import pandas as pd\n", | |
"from IPython.html import widgets # Widget definitions\n", | |
"from IPython.display import display # Used to display widgets in the not\n", | |
"\n", | |
"# Took out\n", | |
"\n", | |
"def on_button_clicked(b):\n", | |
" target_height = target_height_widget.value\n", | |
" target_height_widget.times_clicked += 1\n", | |
" calculate_and_write_file(target_height, target_height_widget.times_clicked)\n", | |
" \n", | |
"def calculate_and_write_file(target_height, filenum):\n", | |
" print \"Using a height of {}\\\".\".format(target_height)\n", | |
" raise WindowsError(\"Because you're going to blame it anyway.\")\n", | |
"\n", | |
"target_height_widget = widgets.IntTextWidget()\n", | |
"target_height_widget.times_clicked = 0\n", | |
"display(target_height_widget)\n", | |
"button = widgets.ButtonWidget(description=\"Calculate and Write File\")\n", | |
"display(button)\n", | |
"button.on_click(on_button_clicked)\n", | |
"\n" | |
], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"Automatic pdb calling has been turned ON\n" | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"Using a height of 10\".\n" | |
] | |
}, | |
{ | |
"ename": "WindowsError", | |
"evalue": "Because you're going to blame it anyway.", | |
"output_type": "pyerr", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mWindowsError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-4-c024106c153d>\u001b[0m in \u001b[0;36mon_button_clicked\u001b[1;34m(b)\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[0mtarget_height\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mtarget_height_widget\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvalue\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mtarget_height_widget\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtimes_clicked\u001b[0m \u001b[1;33m+=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 12\u001b[1;33m \u001b[0mcalculate_and_write_file\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget_height\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtarget_height_widget\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtimes_clicked\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 13\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcalculate_and_write_file\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget_height\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfilenum\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m<ipython-input-4-c024106c153d>\u001b[0m in \u001b[0;36mcalculate_and_write_file\u001b[1;34m(target_height, filenum)\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mcalculate_and_write_file\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget_height\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfilenum\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"Using a height of {}\\\".\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget_height\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 16\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mWindowsError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Because you're going to blame it anyway.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[0mtarget_height_widget\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwidgets\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mIntTextWidget\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mWindowsError\u001b[0m: Because you're going to blame it anyway." | |
] | |
}, | |
{ | |
"output_type": "stream", | |
"stream": "stdout", | |
"text": [ | |
"> \u001b[1;32m<ipython-input-4-c024106c153d>\u001b[0m(16)\u001b[0;36mcalculate_and_write_file\u001b[1;34m()\u001b[0m\n", | |
"\u001b[1;32m 15 \u001b[1;33m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"Using a height of {}\\\".\"\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtarget_height\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[0m\u001b[1;32m---> 16 \u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mWindowsError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Because you're going to blame it anyway.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[0m\u001b[1;32m 17 \u001b[1;33m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[0m\n", | |
"ipdb> \n" | |
] | |
} | |
], | |
"prompt_number": 4 | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment