如何在pdb中设置自定义提示?

How to set a custom prompt in pdb?

正如标题所说——默认的(Pdb)提示符怎么改成别的东西呢? built-in 似乎没有根据 docs or source.

设置提示的方法

一种解决方法是在 .pdbrc 中动态设置它,例如

!(lambda: exec('import gc, pdb; next(o for o in gc.get_objects() if isinstance(o, pdb.Pdb)).prompt = "pdb> "', {}))()

这会导致提示“pdb>”。这也避免了污染本地范围。

或者,使用另一个调试器,例如 pdb++ for which the prompt and other attributes can be configured (per here)。