Python:Canopy>>工作区窗口在哪里?
我正在使用名为Canopy的接口编写Python代码。 我是新手,花了好几个小时找到了工作区窗口,就像Matlab的工作区一样,程序员可以在那里导航找到创建的变量 任何帮助都将不胜感激。Python:Canopy>>工作区窗口在哪里?,python,canopy,Python,Canopy,我正在使用名为Canopy的接口编写Python代码。 我是新手,花了好几个小时找到了工作区窗口,就像Matlab的工作区一样,程序员可以在那里导航找到创建的变量 任何帮助都将不胜感激。 万分感谢 唉,天篷里目前还没有这样的窗格。向他们发送反馈请求帮助->反馈/错误,他们将来可能会将其包括在内。有两种选择: 1您可以使用这样的程序,它有一个工作区窗口 2您可以生成自己的工作区功能: # First note the variables present before we make any. O
万分感谢 唉,天篷里目前还没有这样的窗格。向他们发送反馈请求帮助->反馈/错误,他们将来可能会将其包括在内。有两种选择: 1您可以使用这样的程序,它有一个工作区窗口 2您可以生成自己的工作区功能:
# 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()
并得到如下输出:
x = 5
y = 7
将于10月发布的Canopy 1.5将包括一个GUI调试器,该调试器提供名称空间/变量的显示/浏览以及断点、单步执行代码等调试功能