在 中gdb,我们可以使用它layout src来获得一个非常好的调试文本 UI。pdb(Python 调试器)有等效的东西吗?在 中pdb,我只能看到将要执行的下一行,这很烦人。
gdb text ui如下图所示:
和
python -m pdb -c "c" script.py
Run Code Online (Sandbox Code Playgroud)
当出现问题时,进入调试模式。从文档中,我发现该选项(Python 3.2+)可以让我每次在程序启动时-c "c"点击c + 。Enter
然而,当程序正常完成时,它会输出
The program finished and will be restarted,我仍然需要按q+Enter来退出程序。有没有办法也跳过这个?
有谁知道IronPython 2.6是否计划支持pdb.set_trace()以启用ironpython模块中的断点?如果没有,是否有人建议在没有pdb的情况下完成此操作?
使用pdb.set_trace(),我试图调试一系列表达式,其中j用作索引变量.j = 0不允许的语句,因为j是保留的符号pdb.我怎么能绕过这个?
我正在寻找symstore用于创建目录名称的哈希算法.我发现此链接Microsoft符号服务器/本地缓存哈希算法描述了用于生成哈希的数据元素,但它没有详细说明如何计算哈希值.我有兴趣看看symstore如何生成哈希目录,如果有人有任何可以显示的示例代码,那就太棒了!
我正在使用ipdb调试器在本地调试多线程Web应用程序(Django,Plone).由于我在调试提示符时发生的自动重载,ipdb似乎常常感到困惑.产生的堆栈跟踪出现了
/Users/mikko/code/xxxx/venv/lib/python2.7/site-packages/IPython/core/history.pyc in writeout_cache(self, conn)
605 with self.db_input_cache_lock:
606 try:
--> 607 self._writeout_input_cache(conn)
608 except sqlite3.IntegrityError:
609 self.new_session(conn)
/Users/mikko/code/xxxx/venv/lib/python2.7/site-packages/IPython/core/history.pyc in _writeout_input_cache(self, conn)
589 for line in self.db_input_cache:
590 conn.execute("INSERT INTO history VALUES (?, ?, ?, ?)",
--> 591 (self.session_number,)+line)
592
593 def _writeout_output_cache(self, conn):
ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was created in thread id 4546363392 and this is thread id 140735211872640
Run Code Online (Sandbox Code Playgroud)
在此之后,程序无法关闭(挂起线程)或ipdb本身停止工作.
有没有办法用ipdb迁移这个问题,并使其更安全多线程/自动重载?
编辑:稍微澄清了一下这个问题,因为我认为这可能是IPython问题的根本原因.可能存在某种解决方法,使得IPython只是在重新加载时丢弃历史记录或禁用有问题的IPython SQLite以其他方式写入.
我试图向服务器发出http请求并检查我得到的内容.但是,当我尝试使用HTTPResponse objectwith ipdb,我不断得到*** Oldest frame而且我无法运行我应该能够运行的对象上的任何函数.这是用于获取的代码块和ipdb输出:
代码块:
for acc in sp_lost:
url = 'http://www.uniprot.org/uniprot/?query=mnemonic%3a'+acc+'+active%3ayes&format=tab&columns=entry%20name'
u = urllib.request.urlopen(url)
ipdb.set_trace()
Run Code Online (Sandbox Code Playgroud)
ipdb输出:
ipdb> url
'http://www.uniprot.org/uniprot/?query=mnemonic%3aSPATL_MOUSE+active%3ayes&format=tab&columns=entry%20name'
ipdb> u
*** Oldest frame
ipdb> str(u)
'<http.client.HTTPResponse object at 0xe58e2d0>'
ipdb> type(u)
<class 'http.client.HTTPResponse'>
ipdb> u.url
*** Oldest frame
ipdb> u.url() # <-- unable to run url() on object...?
*** Oldest frame
ipdb>
Run Code Online (Sandbox Code Playgroud)
这是什么*** Oldest frame意思,我怎样才能将这个对象变成更有用的东西,我可以运行相应的函数?
鉴于此示例代码:
import pdb
for i in range(10):
pdb.set_trace()
print(str(i))
Run Code Online (Sandbox Code Playgroud)
当我从PDB得到提示时,我怎样才能跳过循环的迭代,使用continue循环控制语句,当它也被PDB使用时,继续执行代码?
在调试我的Python代码时,我从命令行通过ipdb运行一个脚本,并设置了许多断点.然后我在一个或多个模块中进行一些更改,然后重新运行.但是,如果我只是使用运行模块,请不要重新加载.为了确保它们存在,我可以存在并完全重新启动Python,但是我需要重置所有断点,如果我有很多并且如果一遍又一遍地完成,那么这很麻烦.
有没有办法将断点保存到(i)pdb中的文件中,这样在不改变行号的小改动后,我可以转储断点,重启Python + pdb,然后重新加载断点?相当于Matlabs X = dbstatus,保存/加载X和设置dbstop(X).
我想在Windwos 8上安装Theano
遵循了这些步骤.
我尝试使用测试:
import numpy as np
import time
import theano
print('blas.ldflags=', theano.config.blas.ldflags)
A = np.random.rand(1000, 10000).astype(theano.config.floatX)
B = np.random.rand(10000, 1000).astype(theano.config.floatX)
np_start = time.time()
AB = A.dot(B)
np_end = time.time()
X, Y = theano.tensor.matrices('XY')
mf = theano.function([X, Y], X.dot(Y))
t_start = time.time()
tAB = mf(A, B)
t_end = time.time()
print("NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" % (
np_end - np_start, t_end - t_start))
print("Result difference: %f" % (np.abs(AB - …Run Code Online (Sandbox Code Playgroud) pdb ×10
python ×8
debugging ×3
ipdb ×3
dll ×1
gdb ×1
gdb-python ×1
hash ×1
installation ×1
ipython ×1
ironpython ×1
python-3.x ×1
sqlite ×1
symbols ×1
symstore ×1
theano ×1