Created
September 23, 2018 00:02
-
-
Save simecek/60e3bbce504afa76d2be8186fbf03d62 to your computer and use it in GitHub Desktop.
Debug magic.ipynb
This file contains 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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Debug magic.ipynb", | |
"version": "0.3.2", | |
"provenance": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"[View in Colaboratory](https://colab.research.google.com/gist/simecek/60e3bbce504afa76d2be8186fbf03d62/debug-magic.ipynb)" | |
] | |
}, | |
{ | |
"metadata": { | |
"id": "f8bzRqJ1tzoR", | |
"colab_type": "code", | |
"colab": {} | |
}, | |
"cell_type": "code", | |
"source": [ | |
"def full_speed_ahead(speed=50):\n", | |
" if speed >= 100: raise ValueError(\"Too fast. Speed must be below 100.\")" | |
], | |
"execution_count": 0, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"id": "NB_98bfSuS8r", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 232 | |
}, | |
"outputId": "8091e9a9-dccb-4796-f5e0-aa01c7543708" | |
}, | |
"cell_type": "code", | |
"source": [ | |
"full_speed_ahead(101)" | |
], | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "error", | |
"ename": "ValueError", | |
"evalue": "ignored", | |
"traceback": [ | |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", | |
"\u001b[0;32m<ipython-input-2-2a8abe238f03>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfull_speed_ahead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m101\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[0;32m<ipython-input-1-eb51038e848f>\u001b[0m in \u001b[0;36mfull_speed_ahead\u001b[0;34m(speed)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mfull_speed_ahead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mspeed\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m50\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;32mif\u001b[0m \u001b[0mspeed\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m100\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Too fast. Speed must be below 100.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[0;31mValueError\u001b[0m: Too fast. Speed must be below 100." | |
] | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"id": "ocDUZzbCuX-P", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 153 | |
}, | |
"outputId": "3072b271-0bad-4f8f-a22a-f1ff4400a968" | |
}, | |
"cell_type": "code", | |
"source": [ | |
"%debug" | |
], | |
"execution_count": 3, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"> \u001b[0;32m<ipython-input-1-eb51038e848f>\u001b[0m(2)\u001b[0;36mfull_speed_ahead\u001b[0;34m()\u001b[0m\n", | |
"\u001b[0;32m 1 \u001b[0;31m\u001b[0;32mdef\u001b[0m \u001b[0mfull_speed_ahead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mspeed\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m50\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----> 2 \u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mspeed\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m100\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Too fast. Speed must be below 100.\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", | |
"\u001b[0m\n", | |
"ipdb> speed\n", | |
"101\n", | |
"ipdb> \u0004\n", | |
"\n" | |
], | |
"name": "stdout" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://twitter.com/python_tip/status/946025257932066816