ipdb

Save breakpoints to file

北城以北 提交于 2019-12-01 04:57:28
When debugging my Python code, I run a script through ipdb from the commandline, and set a number of breakpoints. Then I make some changes in one or more modules, and rerun. However, if I simply use run modules do not get reloaded . To make sure they do, I can exist and restart Python completely, but then I need to reset all breakpoints, which is tedious if I have many and if done over and over again. Is there a way to save breakpoint to a file in (i)pdb, so that after small changes that do not change line numbers, I can dump my breakpoints, restart Python + pdb, and reload my breakpoints? The

Save breakpoints to file

左心房为你撑大大i 提交于 2019-12-01 03:08:13
问题 When debugging my Python code, I run a script through ipdb from the commandline, and set a number of breakpoints. Then I make some changes in one or more modules, and rerun. However, if I simply use run modules do not get reloaded. To make sure they do, I can exist and restart Python completely, but then I need to reset all breakpoints, which is tedious if I have many and if done over and over again. Is there a way to save breakpoint to a file in (i)pdb, so that after small changes that do

Exiting Python Debugger ipdb

大兔子大兔子 提交于 2019-11-30 01:24:45
I use ipdb fairly often in a way to just jump to a piece of code that is isolated i.e. it is hard to write a real script that uses it. Instead I write a minimal test case with mocking and jump into it. Exemplary for the workflow: def func(): ... import ipdb ipdb.set_trace() ... def test_case(): ... func() ... Then, invoke py.test test_file.py -s -k test_case Now, usually I just check one variable or two, and then want to quit. Change the code and do it over again. How do I quit? The manual says q quits the debugger. It doesn't (really). You have to quit a few times before the debugger actually

Bdbquit raised when debugging python

天涯浪子 提交于 2019-11-28 23:09:42
Recently when adding the debugger to my python 2.7.10 code, I get this message: Traceback (most recent call last): File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/connectors/amqplib_connector.py", line 191, in acking_callback callback(message.body) File "/Users/isaachess/Programming/vivint/Platform/MessageProcessing/vivint_cloud/queues/consumable_message_queue.py", line 32, in deserialized_callback self._callback_method(msg) File "/Users/isaachess/Programming/vivint/Platform/BusinessLogic/businesslogic/util/statsd_util.py", line 95, in _time_func retVal

Exiting Python Debugger ipdb

白昼怎懂夜的黑 提交于 2019-11-28 22:13:48
问题 I use ipdb fairly often in a way to just jump to a piece of code that is isolated i.e. it is hard to write a real script that uses it. Instead I write a minimal test case with mocking and jump into it. Exemplary for the workflow: def func(): ... import ipdb ipdb.set_trace() ... def test_case(): ... func() ... Then, invoke py.test test_file.py -s -k test_case Now, usually I just check one variable or two, and then want to quit. Change the code and do it over again. How do I quit? The manual

Possible bug in pdb module in Python 3 when using list generators

十年热恋 提交于 2019-11-28 21:20:32
After running this code in Python 3: import pdb def foo(): nums = [1, 2, 3] a = 5 pdb.set_trace() foo() The following expressions work: (Pdb) print(nums) [1, 2, 3] (Pdb) print(a) 5 (Pdb) [x for x in nums] [1, 2, 3] but the following expression fails: (Pdb) [x*a for x in nums] *** NameError: global name 'a' is not defined The above works fine in Python 2.7. Is this a bug or I am missing something? Update : See the new accepted answer. This was indeed a bug (or a problematic design) which has been addressed now by introducing a new command and mode in pdb. if you type interact in your [i]pdb

How to quit ipdb while in post-mortem debugging?

可紊 提交于 2019-11-28 19:16:13
I like to inspect error in a Python script by using: $ python3 -m pdb my_script.py This drops me into a pdb prompt from where I can c continue the execution, and when it hits error, I can inspect the variables and then q quit the script execution to get back to my shell. I tried the same with iPython debugger module, since it is more colorful: $ python3 -m ipdb my_script.py However, I am not able to quit the debugger once I am done inspecting the error. Using the q quit command just keeps switching it between re-executing the script and post-mortem mode: $ python3 -m ipdb my_script.py ipdb> c

using ipdb to debug python code in one cell (jupyter or Ipython)

岁酱吖の 提交于 2019-11-28 15:25:26
I'm using jupyter (or Ipython) notebook with firefox, and want to debug some python code in the cell. I am using 'import ipdb; ipdb.set_trace()' as kind of breakpoint, for example my cell has the following code: a=4 import ipdb; ipdb.set_trace() b=5 print a print b which after execution with Shift+Enter gives me this error: -------------------------------------------------------------------------- MultipleInstanceError Traceback (most recent call last) <ipython-input-1-f2b356251c56> in <module>() 1 a=4 ----> 2 import ipdb; ipdb.set_trace() 3 b=5 4 print a 5 print b /home/nnn/anaconda/lib

Convert generator object to list for debugging [duplicate]

妖精的绣舞 提交于 2019-11-28 03:52:55
This question already has an answer here: Fastest way to convert an iterator to a list 1 answer When I'm debugging in Python using IPython, I sometimes hit a break-point and I want to examine a variable that is currently a generator. The simplest way I can think of doing this is converting it to a list, but I'm not clear on what's an easy way of doing this in one line in ipdb , since I'm so new to Python. Simply call list on the generator. lst = list(gen) lst Be aware that this affects the generator which will not return any further items. You also cannot directly call list in IPython, as it

Possible bug in pdb module in Python 3 when using list generators

ε祈祈猫儿з 提交于 2019-11-27 13:52:42
问题 After running this code in Python 3: import pdb def foo(): nums = [1, 2, 3] a = 5 pdb.set_trace() foo() The following expressions work: (Pdb) print(nums) [1, 2, 3] (Pdb) print(a) 5 (Pdb) [x for x in nums] [1, 2, 3] but the following expression fails: (Pdb) [x*a for x in nums] *** NameError: global name 'a' is not defined The above works fine in Python 2.7. Is this a bug or I am missing something? Update : See the new accepted answer. This was indeed a bug (or a problematic design) which has