[英]custom python IDEA debugger type renderer that requires an import
我正在嘗試在 IDEA Python 調試器中添加自定義類型渲染器。 具體來說,我想將標准 xml package 中的一個883812976388 元素呈現為字符串,例如<xa=1><y>2</y></x>
這樣做的代碼是ElementTree.tostring(self)
,其中self
代表調試器中的變量或監視。
ElementTree 需要導入,所以我沒有成功嘗試:
xml.etree.ElementTree.tostring(self)
和
from xml.etree import ElementTree
ElementTree.tostring(self)
在這兩種情況下,我都收到錯誤Unable to evaluate: name 'xml' is not defined
in the debugger watch window。請參見屏幕截圖:
文檔沒有提到需要導入渲染 function 的情況。
有沒有人能夠這樣做?
經過進一步調查,我設法讓它與動態導入一起工作:
__import__('xml').etree.ElementTree.tostring(self)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.