pdb

Get last exception in pdb

孤街浪徒 提交于 2019-12-18 14:16:09
问题 Is there a way to examine the last exception when in pdb/before entering pdb? (Using python 2.7.5). Immediately (yes, I enter no other commands at all) after an exception being raised in my code, I do sys.exc_info() ; this just results in (None, None, None) . At this point, I can do pdb.pm() , and pdb starts at the point that the exception is raised. I'd like to be able to examine this exception object (it is not stored in a variable before being raised). There is nothing obviously helpful in

How do I set sys.excepthook to invoke pdb globally in python?

不羁的心 提交于 2019-12-18 11:58:15
问题 From Python docs: sys.excepthook(type, value, traceback) This function prints out a given traceback and exception to sys.stderr . When an exception is raised and uncaught, the interpreter calls sys.excepthook with three arguments, the exception class, exception instance, and a traceback object. In an interactive session this happens just before control is returned to the prompt; in a Python program this happens just before the program exits. The handling of such top-level exceptions can be

pdb/ipdb for python break on editable condition

坚强是说给别人听的谎言 提交于 2019-12-18 11:22:54
问题 Say I have code the following code: for i in range(100): print i In general I can add one line to the code as: for i in range(100): import ipdb;ipdb.set_trace() print i However, now I want to debug it at condition of i == 10 , and I don't want to bother by typing c for 10 times in ipdb, how should I do? In the documentation I found condition bpnumber [condition] , but how could I know the bpnumber if there is no list of bpnumber index. The documentation also says b(reak) ([file:]lineno |

Simpler way to put PDB breakpoints in Python code?

时间秒杀一切 提交于 2019-12-17 10:14:58
问题 Just a convenience question. I've been a bit spoiled with debuggers in IDEs like Visual Studio and XCode. I find it a bit clumsy to have to type import pdb; pdb.set_trace() to set a breakpoint (I'd rather not import pdb at the top of the file as I might forget and leave it in). Is there a simpler way of setting a breakpoint in Python code, as straightforward and unobtrusive as what you see in an IDE? 回答1: You can run your program into pdb from the command line by running python -m pdb your

cannot override sys.excepthook

末鹿安然 提交于 2019-12-17 09:57:25
问题 I try to customize behavior of sys.excepthook as described by the recipe. in ipython: :import pdb, sys, traceback :def info(type, value, tb): : traceback.print_exception(type, value, tb) : pdb.pm() :sys.excepthook = info :-- >>> x[10] = 5 ------------------------------------------------- Traceback (most recent call last): File "<ipython console>", line 1, in <module> NameError: name 'x' is not defined >>> pdb.pm() is not being called. It seems that sys.excepthook = info doesn't work in my

cannot override sys.excepthook

南笙酒味 提交于 2019-12-17 09:56:19
问题 I try to customize behavior of sys.excepthook as described by the recipe. in ipython: :import pdb, sys, traceback :def info(type, value, tb): : traceback.print_exception(type, value, tb) : pdb.pm() :sys.excepthook = info :-- >>> x[10] = 5 ------------------------------------------------- Traceback (most recent call last): File "<ipython console>", line 1, in <module> NameError: name 'x' is not defined >>> pdb.pm() is not being called. It seems that sys.excepthook = info doesn't work in my

Visual Studio 2010 “Cannot find or open the PDB file”

情到浓时终转凉″ 提交于 2019-12-17 09:49:44
问题 I try to debug a program in Visual Studio 10, but I have a problem with breakpoints. I put *.pdb files corresponding to the *.dll files to the same directory. But while checking modules, I see that each DLL file is signed as Cannot find or open the PDB file . How can I fix this problem? How can I check where *.pdb files are expected to be located? 回答1: The modules (Ctrl-D, M) is a good place to sort out whats going on so you're in the right area. Right-click the module/dll you expected the

Pycharm debuge调试如何参数输入+命令行调试器 之pdb

ぃ、小莉子 提交于 2019-12-17 09:03:23
今天在GAN代码调试过程中发现一个问题,一直以来运行都在可视化情况下运行调试,今天突然想用命令行调试。由于需要输入文件导入参数。下面记录一下 首先在Run->Edit Configurations-->找到下面一行 parameters;里面输入你需要运行的命令 注意:这里我运行的是一个kdd99.txt的 文本格式的,在 parameters中最后不要加上格式.txt 因为系统会自动识别这个文件的类型。如果加上了 在运行的时候就会报错 因为系统会将文件识别为 kdd99.txt.txt导致出错 使用PDB的方式有两种: 1. 单步执行代码,通过命令 python -m pdb xxx.py 启动脚本,进入单步执行模式 2. pdb单步执行太麻烦了,所以第二种方法是import pdb 之后,直接在代码里需要调试的地方放一个pdb.set_trace(),就可以设置一个断点, 程序会在pdb.set_trace()暂停并进入pdb调试环境,可以用pdb 变量名查看变量,或者c继续运行 注意: 1:直接输入Enter,会执行上一条命令(这里我尝试了似乎并没有效果 我的pycharm 版本是11.04); 2:输入PDB不认识的命令,PDB会把他当做Python语句在当前环境下执行; 如果想查看参数,一定要运行完以后才可以看参数值。 例如这里我运行完以后 输出settings

Reading an entire directory of .pdb files using BioPython

时光怂恿深爱的人放手 提交于 2019-12-13 07:30:39
问题 I was recently tasked to write a program in python to find atoms within 2 angstroms distance from every metal in a protein from a .pdb (Protein Data Bank). This is the script I wrote for it. from Bio.PDB import * parser = PDBParser(PERMISSIVE=True) def print_coordinates(list): neighborList = list for y in neighborList: print " ", y.get_coord() structure_id = '5m6n' fileName = '5m6n.pdb' structure = parser.get_structure(structure_id, fileName) atomList = Selection.unfold_entities(structure, 'A

missing pdb file

人盡茶涼 提交于 2019-12-12 09:44:54
问题 I'm debugging my app on a wince7 device. After couple minutes I'm getting an error: "No symbols are loaded for any call stack frame. The source code cannot be displayed." I noticed on the modules list that I have 1 dll that is missing pdb file. Its name is System.Drawing.dll . I noticed that the module added to the module list after some thread (that I'm not creating and I don't know who) is created. I'm getting the error only after the thread is running. Anyone know where can I find the