在PyCharm调试模式下,有没有办法让它在遇到错误后立即停止但不退出并突出显示有问题的行?我想到的类似功能是Matlab的“发生错误时停止”。
对我来说,我所做的就是检测不可选取的内容并将其放入字符串中(我想我也可以将其删除,但随后它会错误地告诉我该字段不存在,但我宁愿让它存在但成为字符串) )。但我想知道是否有一种不那么老套、更正式的方式来做到这一点。
我当前使用的代码:
def make_args_pickable(args: Namespace) -> Namespace:
"""
Returns a copy of the args namespace but with unpickable objects as strings.
note: implementation not tested against deep copying.
ref:
- /sf/ask/4908983481/
"""
pickable_args = argparse.Namespace()
# - go through fields in args, if they are not pickable make it a string else leave as it
# The vars() function returns the __dict__ attribute of the given object.
for field in vars(args):
field_val: Any = getattr(args, field)
if not dill.pickles(field_val): …Run Code Online (Sandbox Code Playgroud)