2014-09-25 59 views
0

我使用名爲Canopy的接口來編寫Python。 我對此很陌生,花了好幾個小時才找到工作空間窗口(就像Matlab的工作空間,程序員可以導航以找到創建的變量)Python:Canopy >>工作區窗口在哪裏?

任何幫助將被珍惜。 巨大的感謝提前! enter image description here

回答

0

唉,Canopy目前沒有這樣的窗格。向他們發送反饋請求(幫助 - >反饋/錯誤),他們可能會在將來包括它。有幾個選項:

1)您可以使用像PyCharm這樣的程序,它有一個工作區窗口。

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 
0

雨棚1.5,10月到期,將包括一個GUI調試器,它提供名稱空間/變量的顯示/瀏覽(以及調試功能,如斷點,單步執行代碼等)。