pdb

How to extract specific columns from a space separated file in Python?

无人久伴 提交于 2019-12-01 01:15:43
I'm trying to process a file from the protein data bank which is separated by spaces (not \t). I have a .txt file and I want to extract specific rows and, from that rows, I want to extract only a few columns. I need to do it in Python. I tried first with command line and used awk command with no problem, but I have no idea of how to do the same in Python. Here is an extract of my file: [...] SEQRES 6 B 80 ALA LEU SER ILE LYS LYS ALA GLN THR PRO GLN GLN TRP SEQRES 7 B 80 LYS PRO HELIX 1 1 THR A 68 SER A 81 1 14 HELIX 2 2 CYS A 97 LEU A 110 1 14 HELIX 3 3 ASN A 122 SER A 133 1 12 [...] For

Django Gunicorn Debug

蓝咒 提交于 2019-12-01 00:16:40
问题 Initially I had a Django app with the included testing server. To debug this setup, I can just add a import pdb; pdb.set_trace() anywhere in the code and have a breaking point that throws me into an interactive debugger in Terminal (on command-line). Recently I shifted to gunicorn to gain some perf benifits. How can I get a similar behavior while using this Gunicorn setup. I have tried by setting gunicorn settings with debug=True and daemon=False but it does not work. Anyone has a solution to

Run pdb without stdin/stdout using FIFO

岁酱吖の 提交于 2019-11-30 21:42:41
I am developing FUSE filesystem with python. The problem is that after mounting a filesystem I have no access to stdin/stdout/stderr from my fuse script. I don't see anything, even tracebacks. I am trying to launch pdb like this: import pdb pdb.Pdb(None, open('pdb.in', 'r'), open('pdb.out', 'w')).set_trace() All works fine but very inconvenient. I want to make pdb.in and pdb.out as fifo files but don't know how to connect it correctly. Ideally I want to type commands and see output in one terminal, but will be happy even with two terminals (in one put commands and see output in another).

How to extract specific columns from a space separated file in Python?

ε祈祈猫儿з 提交于 2019-11-30 20:48:13
问题 I'm trying to process a file from the protein data bank which is separated by spaces (not \t). I have a .txt file and I want to extract specific rows and, from that rows, I want to extract only a few columns. I need to do it in Python. I tried first with command line and used awk command with no problem, but I have no idea of how to do the same in Python. Here is an extract of my file: [...] SEQRES 6 B 80 ALA LEU SER ILE LYS LYS ALA GLN THR PRO GLN GLN TRP SEQRES 7 B 80 LYS PRO HELIX 1 1 THR

使用pdb调试代码

巧了我就是萌 提交于 2019-11-30 18:08:59
在开发简单程序的时候,可以通过加入print或log的方法进行程序的调试. 但是对过于复杂的程序这种方式往往比较困难,这时就需要引入一种可以进行单步调试以及可以方便查看变量的方法来进行 程序问题的排查,Python的pdb就是用来解决这个问题的. 常用命令 通常使用pdb.set_trace()来打断点 Command Desc break或b 设置断点 continue或c 继续执行程序,或是跳到下个断点 list或l 查看当前行的代码段 step或s 进入函数 return或r 执行代码直到从当前函数返回 exit或q 中止或推出 next或n 执行下一行 p或! 打印变量的值. help或h 帮助 实例: #utils.py def add(a, b): return a + b # main.py import utils def cal(a, b): import pdb pdb.set_trace() c = utils.add(a, b) print(c) return c if __name__ == "__main__": cal(3, 4) 来源: https://my.oschina.net/u/2474096/blog/3112671

conditional breakpoint using pdb

随声附和 提交于 2019-11-30 15:49:30
Sounds like I'm missing something extremely simple, I'm trying to set a breakpoint in my python code using: if(some condition): pdb.set_trace() My error in the code comes after a large number of iterations..difficult to debug using print etc. I am able to print stuff when the condition hits but I would like to set brk-pt. --EDIT-- Actual code: import pdb if (node_num == 16): print node_num pdb.set_trace() I am not sure as to why your code isn't working, but what you can do is on your local machine, create a new file for your minimum example to see if you can do what you want to do import pdb

How to define a new function in pdb

核能气质少年 提交于 2019-11-30 14:52:24
问题 Why can't I define new functions when I run pdb ? For example take myscript.py: #!/gpfs0/export/opt/anaconda-2.3.0/bin/python print "Hello World" print "I see you" If I run python -m pdb myscript.py and try to interactively define a new function: def foo(): I get the error: *** SyntaxError: unexpected EOF while parsing (<stdin>, line 1) Why is this? 回答1: You can define your function in a one line statement using ; instead of indentation, like this: (Pdb) def foo(): print 'Hello world'; print

How to define a new function in pdb

萝らか妹 提交于 2019-11-30 12:17:45
Why can't I define new functions when I run pdb ? For example take myscript.py: #!/gpfs0/export/opt/anaconda-2.3.0/bin/python print "Hello World" print "I see you" If I run python -m pdb myscript.py and try to interactively define a new function: def foo(): I get the error: *** SyntaxError: unexpected EOF while parsing (<stdin>, line 1) Why is this? You can define your function in a one line statement using ; instead of indentation, like this: (Pdb) def foo(): print 'Hello world'; print 'I see you' (Pdb) foo() Hello world I see you I don't think it supports multi-line input. You can workaround

Get last exception in pdb

核能气质少年 提交于 2019-11-30 11:16:34
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 http://docs.python.org/2/library/pdb.html or http://docs.python.org/2/library/sys.html Edit: I know

[调试]_[初级]_[Windbg使用教程-2]

笑着哭i 提交于 2019-11-30 10:20:38
场景 1.我们开发C++程序时, 发布给客户用的是Release模式, 并添加崩溃报告,在程序崩溃退出时,可以通过使用WinDbg来调试崩溃产生的dmp文件. 2.我们也可以用来调试程序, 加断点, 看局部变量,只是这里主要还是讲调试dmp的. 说明 1.Windbg并不是系统标配的, 需要通过SDK下载安装. Debugging Tools for Windows . WinDbg, 一个独立的图形Debug工具, 可以调试用户模式和内核模式. 相当于vs的调试器独立版本,或者说是linux里的gdb. 如果配合Windows SDK的C++编译工具, 甚至不需要VS都可以用SDK自带的编译工具和WinDbg开发程序. 2.获取Windows dll pdb文件可以通过两种方式: – 方式1: 启动windbg后,在[Symbol Search Path] 对话框中加入下面的路径: srv*D:\SystemSymbols*http://msdl.microsoft.com/download/symbols 这种方式就是在调试过程中,windbg调试器会从符号表服务器自动下载调试所需的PDB文件. – 方式2: 预先下载PDB文件,这样能减少调试的等待时间. "C: \Program Files \Debugging Tools for Windows (x86) \symchk