pdb

中快捷方便的调试利器pdb

微笑、不失礼 提交于 2019-12-03 04:27:52
1.终端命令行中进入调试模式 python -m pdb xxx.py 2.Jupyter中进入调试模式 1.异常的显示方式 %Verbose 详细显示 %Plain 简单显示 2.进入调试模式的方法 任何时候都可以进入调试,在代码需要调试的部分,使用pdb包里的.set_trace()方法,进入pdb调试模式 异常后手动进入调试,发生异常后,手动输入%debug进入pdb调试模式 异常后自动进入调试,前部加%pdb on,当发生异常后自动进入pdb调试模式 3.调试快捷键 设置断点 b 行数n : 在当前文件的n行设置断点 调试操作 n : 单步运行,不进入函数 s : 单步运行,可进入函数 c : 恢复执行,至下一个断点 u/d :在函数调用栈中上下移动 q : 退出调试 其中:可以用 Enter 重复前一个命令 查看变量 !vname 或者 p vname :可查看变量的内容 4.显示行号 点击View-->点击Toggle Line Numbers 2.代码示范 1.任何时候都可以进入调试,在代码需要调试的部分,使用pdb包里的.set_trace()方法,进入pdb调试模式 import pdb pdb.set_trace() def chu(a,b): c = a/b return c a = 1 b = 0 c = chu(a,b) --Return-- >

Stepping into a function in IPython

笑着哭i 提交于 2019-12-03 03:34:05
问题 Is there a way to step into the first line of a function in ipython. I imagine something that would look like: %step foo(1, 2) which runs ipdb and sets a breakpoint at the first line of foo . If I want to do this now I have to go to the function's source code and add an import ipdb; ipdb.set_trace() line. 回答1: ipdb has had support for runcall, runeval and run since 0.7, earlier this year. You can use it just like pdb.runcall : In [1]: def foo(a, b): ...: print a + b ...: In [2]: import ipdb

WinDbg cannot find symbols for ntdll on MS symbol server

匿名 (未验证) 提交于 2019-12-03 03:03:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to debug executable notepad.exe (from Windows 10 distribution), and symbols ntdll.pdb from Microsoft symbols server are required, but debugger returns an error that they cannot find file specified: 0:000> .reload Reloading current modules ................................. SYMSRV: BYINDEX: 0x25 http://msdl.microsoft.com/download/symbols ntdll.pdb BC08E2B7EBB349A18DCE18BE9AA6660E1 SYMSRV: HTTPGET: /download/symbols/ntdll.pdb/BC08E2B7EBB349A18DCE18BE9AA6660E1/ntdll.pdb SYMSRV: HttpQueryInfo: 404 - HTTP_STATUS_NOT_FOUND SYMSRV:

sh: Syntax error: Bad fd number [closed]

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need some help in running this code. I took this code from ( http://easybioinfo.free.fr/?q=content/amber-trajectory-gromacs-xtc-conversion ). I am trying to convert amber trajectory to gromacs trajectory. When I execute this code, I get some errors. I paste the errors below this code: #!/usr/bin/python #Workflow based on Trajectory Converter - v1.5 by: Justin Lemkul #completely reimplemented and improved by Peter Schmidtke & Jesus Seco import sys,os,re,fnmatch if len(sys.argv)>4 : f=sys.argv[1] if not os.path.exists(f): sys.exit(" ERROR :

column replacement with awk, with retaining the format

匿名 (未验证) 提交于 2019-12-03 02:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a a.pdb file as, ATOM 1 N ARG 1 0.000 0.000 0.000 1.00 0.00 N ATOM 2 H1 ARG 1 0.000 0.000 0.000 1.00 0.00 H ATOM 3 H2 ARG 1 0.000 0.000 0.000 1.00 0.00 H ATOM 4 H3 ARG 1 0.000 0.000 0.000 1.00 0.00 H and a.xyz file as 16.388 -5.760 -23.332 17.226 -5.608 -23.768 15.760 -5.238 -23.831 17.921 -5.926 -26.697 I want to replace 6,7 and 8th column of a.pdb with a.xyz. Once replaced, I need to maintain tabs/space/columns of a.pdb. I have tried awk 'NR==FNR {fld1[NR]=$1; fld2[NR]=$2; fld3[NR]=$3; next} {$6=fld1[FNR]; $7=fld2[FNR]; $8=fld3[FNR]

How to print all variables values when debugging Python with pdb, without specifying each variable?

白昼怎懂夜的黑 提交于 2019-12-03 02:27:23
问题 I'm debugging my Python scripts using pdb and the manual says I can use p variables command to print the values of the specified variables at a certain point. But what if I had lots of variables, like 20 variables, and I would like to track the value of all of them? How do I print all of them without specifying each one manually? Take for example this script: a = 1 b = 2 c = 3 I can debug it with pdb and print all of them using p a, b, c like this: $ python -m pdb test.py > /media/test.py(1)

理解 Oracle 多租户体系中(12c,18c,19c)Grant授权作用域范围

依然范特西╮ 提交于 2019-12-03 01:56:52
本篇探讨以下几个问题:你可提前猜测下面6个场景语句中,哪几个授权可以成功执行? 1. 在CDB级别中对用户进行授权,不带 container 子句的效果; 2. 在CDB级别中对用户进行授权,带 container=all 子句的效果; 3. 在CDB级别中对用户进行授权,带 container=current 子句的效果; 4. 在PDB级别中对用户进行授权,不带 container 子句的效果; 5. 在PDB级别中对用户进行授权,带 container=all 子句的效果; 6. 在PDB级别中对用户进行授权,带 container=current 子句的效果; 在理解上面问题之前,我们需要提前约定,就是需要提前知道: 1. CDB级别 创建的用户或角色称为 公共用户或角色 , PDB级别 创建的用户或角色称为 本地用户或角色 。且CDB级别无法对公共用户和角色无法进行 container=current 操作,PDB级别无法对本地用户进行 container=all 操作。 2. 公共 用户和角色 命名规则对应参数 common_user_prefix ,该参数值默认为 C## 。所以,在CDB级别创建公共用户或角色,需要带 C## (也可以更改参数值,但不建议)。 3. PDB$SEED 仅为种子容器,对应 CON_ID 为 2,只读模式,不参与讨论。 演示数据库版本

Bdbquit raised when debugging python

匿名 (未验证) 提交于 2019-12-03 01:49:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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

Debugging python programs in emacs

橙三吉。 提交于 2019-12-03 00:35:50
问题 How to debug python programs in emacs? I use python-mode.el I get reference like import pdb; pdb.set_trace(); but not sure how to use it. 回答1: Type M-x cd to change directory to the location of the program you wish to debug. Type M-x pdb . You'll be prompted with Run pdb (like this): pdb . Enter the name of the program (e.g. test.py ). At the (Pdb) prompt, type help to learn about how to use pdb. Alternatively, you can put import pdb pdb.set_trace() right inside your program (e.g. test.py ).

C++用sqlite3_open连接打开指定数据库的小问题

匿名 (未验证) 提交于 2019-12-02 23:49:02
一开始我也纳闷,我以为是我数据库没弄好,但是当我仔细检查,才发现 原来我少了分号 所以用的时候需要注意。。。 代码部分: #include "stdafx.h" #include "sqlite3.h" #include <iostream> using namespace std; sqlite3 * pDB = NULL; int _tmain(int argc, _TCHAR* argv[]) { //打开路径采用utf-8编码 //如果路径中包含中文,需要进行编码转换   //指定数据库路径记得写全 并加上 分号 " ; " int nRes = sqlite3_open("D:\\sqlite\\fuck.db;", &pDB); if (nRes != SQLITE_OK) { cout << "Open database fail: " << sqlite3_errmsg(pDB); goto QUIT; } else { cout << "打开数据库成功!" << endl; } QUIT: sqlite3_close(pDB); return 0; }