2011-06-09 56 views

回答

2

你想要code

+4

很多人来StackOverflow,因为他们想要的代码。只是一个观察:-) – Johnsyweb 2011-06-09 02:29:32

5

查看code模块。

下面是一个例子:

import code 
a = 1 
b = 2 
code.interact(local=locals()) 

输出:

Python 2.7 (r27:82500, Nov 10 2010, 22:46:43) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin 
Type "help", "copyright", "credits" or "license" for more information. 
(InteractiveConsole) 
>>> a 
1 
>>> b 
2 
>>> 
1

相反,当你从运行巨蟒(没有脚本文件),或者从IPython中得到的,你要开始一个REPL的debugger

def example(a, b, c): 
    a.apple(b.blah() + c) 

    import pdb 
    pdb.set_trace() 

    c.continuing_on() 
    while inspecting(this.code()) in the_debugger: 
    print "hooray" 

您可以从pdb执行任意代码,但它也有方便的命令来检查,同时继续运行现有的代码。

相关问题