# First note the variables present before we make any. Only variables made after this line are part of the "workspace"
locvars = locals().copy()
# Print out an list of variables that aren't python internal. We will call the workspace the collection
# of variables which were made after the first instruction executed.
# This function expects the calling namespace to have a variable locvars which is a copy of locals taken before
# any variables were made for inclusion into the "workspace".
def showlocals():
# Get the calling frame's locals
import inspect
locs = inspect.currentframe().f_back.f_locals
locvars = locs['locvars']
# Get the list of variables in the workspace.
workspace = [k for (k, v) in locs.items() if k not in locvars.keys() and k[0] != '_' and k != 'locvars' and k != 'showlocals']
# Print out the names and values of those.
for (k,v) in locs.items():
if k in workspace:
print '%s = %s' % (k, v)
# Now you do your code which produces variables.
x = 5
y = 7
# Everytime you want to print out the variables you call this function.
showlocals()
Canopy1.5将于10月份发布,它将包含一个GUI调试器,该调试器提供名称空间/变量的显示/浏览(以及诸如断点、单步执行代码等调试功能)。在
唉,天棚里现在还没有这样的窗格。向他们发送反馈请求(帮助->反馈/错误),他们可能会在将来将其包括在内。有两种选择:
1)可以使用PyCharm这样的程序,它有一个工作区窗口。在
2)您可以生成自己的“工作区”功能:
得到如下输出:
^{pr2}$相关问题 更多 >
编程相关推荐