pdb

How do you watch a variable in pdb

ε祈祈猫儿з 提交于 2019-11-27 00:05:56
问题 I'm debugging a python script, and I want to watch a variable for a change (much like you can watch a memory adress in gdb). Is there a way to do this? 回答1: For watching a variable when you are hitting a breakpoint , you can use the commands command. E.g. printing some_variable when hitting breakpoint #1 (canonical example from pdb doc). (Pdb) commands 1 (com) print some_variable (com) end (Pdb) Update for Python 3 (Pdb) commands 1 (com) print(some_variable) (com) end (Pdb) Additionally, you

Watch for a variable change in python

风格不统一 提交于 2019-11-26 19:47:13
问题 There is large python project where one attribute of one class just have wrong value in some place. It should be sqlalchemy.orm.attributes.InstrumentedAttribute, but when I run tests it is constant value, let's say string. There is some way to run python program in debug mode, and run some check (if variable changed type) after each step throught line of code automatically? P.S. I know how to log changes of attribute of class instance with help of inspect and property decorator. Possibly here

How to execute multi-line statements within Python's own debugger (PDB)

◇◆丶佛笑我妖孽 提交于 2019-11-26 18:45:30
问题 So I am running a Python script within which I am calling Python's debugger, PDB by writing: import ipdb; ipdb.set_trace() (iPython's version of PDB, though for the matter I don't think it makes a difference; I use it for the colored output only). Now, when I get to the debugger I want to execute a multi-line statement such as an if clause or a for loop but as soon as I type if condition: and hit the return key, I get the error message *** SyntaxError: invalid syntax (<stdin>, line 1) How can

Step-by-step debugging with IPython

£可爱£侵袭症+ 提交于 2019-11-26 18:42:43
问题 From what I have read, there are two ways to debug code in Python: With a traditional debugger such as pdb or ipdb . This supports commands such as c for continue , n for step-over , s for step-into etc.), but you don't have direct access to an IPython shell which can be extremely useful for object inspection. Using IPython by embedding an IPython shell in your code. You can do from ipython import embed , and then use embed() in your code. When your program/script hits an embed() statement,

What is the right way to debug in iPython notebook?

核能气质少年 提交于 2019-11-26 15:01:05
问题 As I know, %debug magic can do debug within one cell. However, I have function calls across multiple cells. For example, In[1]: def fun1(a) def fun2(b) # I want to set a breakpoint for the following line # return do_some_thing_about(b) return fun2(a) In[2]: import multiprocessing as mp pool=mp.Pool(processes=2) results=pool.map(fun1, 1.0) pool.close() pool.join What I tried: I tried to set %debug in the first line of cell-1. But it enter into debug mode immediately, even before executing cell

Remove PDB references from released file

℡╲_俬逩灬. 提交于 2019-11-26 14:24:22
问题 I use to take always a look at the final binary executable or dll after debugging and creating a file with any IDE. Now I am trying Visual C++ 2010, in the search for the best release, without trash or unnecessary references. So, I created a new solution with two projects: a executable and its dll. VC++ created a lot of intermediary files between the code and the final file. I opened the .exe and the .dll with a hexadecimal editor and saw something that I don't like. Somewhere inside the file

Getting started with the Python debugger, pdb [closed]

百般思念 提交于 2019-11-26 04:03:09
问题 I want to add pdb—the Python debugger—to my toolbox. What\'s the best way to get started? 回答1: Here's a list of resources to get started with the Python debugger: Read Steve Ferb's article "Debugging in Python" Watch Eric Holscher's screencast "Using pdb, the Python Debugger" Read the Python documentation for pdb — The Python Debugger Read Chapter 9—When You Don't Even Know What to Log: Using Debuggers—of Karen Tracey's Django 1.1 Testing and Debugging. 回答2: Synopsis: # epdb1.py -- experiment