簡體   English   中英

Python如何在與pdb上下文中的args關鍵字沖突時打印args變量

[英]Python how to print args variable when it conflicts with args keyword in pdb context

'args'變量名在我的項目中使用。 當我使用pdb.set_trace進行調試時,我想打印'args'變量中的內容。 結果與我的期望大不相同,我發現pdb使用'args'作為保留字以保留其他內容。 我的問題是如何打印這個'args'變量,而不必將變量名稱更改為不沖突的東西。 謝謝。

我在Windows命令行控制台中使用Python 3.4。 Python偽代碼示例:

args = dict(blah='blah'...)
... some code deal with args
def foo():
  pdb.set_trace() # when traced here, I type 'args' to show what it is, but looks like it's going to print arguments of foo method, which is None.
foo() 

好。 我想到了。 使用pdb命令,p(args)或pp(args)應該保存它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM