pdb

Interrupt (pause) running Python program in pdb?

痞子三分冷 提交于 2019-11-30 07:27:36
问题 In gdb, you can interrupt(pause) the program by C-c and resume. Can you do this in pdb? 回答1: Based on this bug report it might be fixed in Python 3. In 2.x Ctrl-C will throw a KeyboardInterrupt, which is typically unhandled by the program, and will put the debugger into 'post-mortem' mode. You cannot continue where you left off. I don't know if there's some other way to do what you are describing. 回答2: No, python2's pdb doesn't support this, but you add this code to your program as a

Python debugger: Stepping into a function that you have called interactively

与世无争的帅哥 提交于 2019-11-30 06:39:52
问题 Python is quite cool, but unfortunately, its debugger is not as good as perl -d. One thing that I do very commonly when experimenting with code is to call a function from within the debugger, and step into that function, like so: # NOTE THAT THIS PROGRAM EXITS IMMEDIATELY WITHOUT CALLING FOO() ~> cat -n /tmp/show_perl.pl 1 #!/usr/local/bin/perl 2 3 sub foo { 4 print "hi\n"; 5 print "bye\n"; 6 } 7 8 exit 0; ~> perl -d /tmp/show_perl.pl Loading DB routines from perl5db.pl version 1.28 Editor

Launch Python debugger while simultaneously executing module as script

寵の児 提交于 2019-11-30 06:39:38
问题 When developing a Python package, it's very convenient to use the -m option to run modules inside the package as scripts for quick testing. For example, for somepackage with module somemodule.py inside it, invoking python -m somepackage.somemodule from the directory where somepackage resides will run somemodule.py as though the submodule were __main__ . Using this calling syntax is especially important if the package is using explicit relative imports as described here. Similarly, it is also

Oracle12c创建及删除PDB

廉价感情. 提交于 2019-11-30 06:33:21
  在12C R1版本中只支持Global Shared Undo模式,所有container共享一个UNDO表空间;在12C R2引入了PDB Local Undo模式,每个container都有自己的UNDO 表空间,对于RAC是每 个实例每个container都有自己的UNDO表空间。在DBCA时会有Local Undo选项,且默认勾选。   在12c R1版本中clone PDB源库需要打开在read only只读模式 ,12c R2版本中引入了local undo mode, PDB源库在read write读写模式也可以clone。 克隆PDB要求:   1. Archive Log Enabled   2. Local Undo Enabled   3. destination CDB must have a public database link to the source CDB,have sufficient privileges to use the database link 可以通过图形化工具DBCA、命令行、em express等方式创建和删除PDB,该处只描述命令行方式操作。 一、创建PDB 1. 克隆种子容器 SQL> select * from v$dbfile;      #查看路径 SQL> show parameter db_create

Can I debug with python debugger when using py.test somehow?

天涯浪子 提交于 2019-11-30 06:28:53
问题 I am using py.test for unit testing my python program. I wish to debug my test code with the python debugger the normal way (by which I mean pdb.set_trace() in the code) but I can't make it work. Putting pdb.set_trace() in the code doesn't work (raises IOError: reading from stdin while output is captured). I have also tried running py.test with the option --pdb but that doesn't seem to do the trick if I want to explore what happens before my assertion. It breaks when an assertion fails, and

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

故事扮演 提交于 2019-11-30 05:21:05
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 customized by assigning another three-argument function to sys.excepthook . http://docs.python.org

pdb/ipdb for python break on editable condition

半世苍凉 提交于 2019-11-30 05:00:43
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 | function) [, condition] . For example, assume the line number of print i is xx . I entered the following in

Getting pdb in Emacs to use Python process from current virtualenv

我与影子孤独终老i 提交于 2019-11-30 04:44:20
I am debugging some python code in emacs using pdb and getting some import issues. The dependencies are installed in one of my bespoked virtualenv environments. Pdb is stubbornly using /usr/bin/python and not the python process from my virtualenv. I use virtualenv.el to support switching of environments within emacs and via the postactivate hooks described in http://jesselegg.com/archives/2010/03/14/emacs-python-programmers-2-virtualenv-ipython-daemon-mode/ This works well when running M-x python-shell >>> import sys >>> print sys.path This points to all of my virtualenv libraries indicating

Is there a free python debugger that has watchpoints? [closed]

∥☆過路亽.° 提交于 2019-11-30 03:35:25
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . pdb and winpdb both seem to be missing this essential (to me) feature. I saw something suggesting WingIDE has it but I'd prefer a solution that is free, and if I do have to pay, I'd prefer to pay for something that is better than Wing. 回答1: Please look what pydev in eclipse offers... 回答2: You should check out

Python调试器,快速定位各种疑难杂症

和自甴很熟 提交于 2019-11-30 00:58:33
现在很多的编辑器其实都带着「调试程序」的功能,比如写 c/c++ 的 codeblocks,写 Python 的 pycharm,这种图形界面的使用和显示都相当友好,简单方便易学,这个不是我这篇文章要讲的重点。今天主要是想给大家介绍一下 「 Python调试器 」,快速定位各种疑难杂症。 Python 调试器 这一部分主要就是想说两个 Python 调试器,分别是标准库自带的 pdb 和开源的 ipdb。 pdb pdb 是 Python 自带的库,为 Python 提供了一种交互式的源码调试功能,包含当前调试器应有的功能,包括设置断点、单步调试、查看源码等。其实如果你之前学过 c/c++ 的话,你可能知道 gdb 这个命令行调试工具,如果你之前用过 gdb,那么恭喜你你可以直接用 pdb 了,因为这哥俩一个用法。如果你不知道 gdb 也没事,我们先来看一下 pdb 的部分调试命令: 这里有两种不同的方法来启动 Python 调试器,两种方法适用于不同的场景。一种是直接在命令行参数指定使用 pdb 模块启动 Python 文件, 这种适合于代码文件较短的情况 ,将在代码的第一行启动 Python 调试器。具体如下所示(例如文件名是 test.py): python -m pdb test.py 另一种是在 Python 代码中调用 pdb 模块的 set_trace