开发者

good idea to modify Python to accept continue statement in interactive mode?

开发者 https://www.devze.com 2023-02-01 11:08 出处:网络
as an alternative to using pdb, I would have a use for the Python continue statement in interactive mode, after control-C during a script invocation with python -i. that way, say at a raw_input(\'cont

as an alternative to using pdb, I would have a use for the Python continue statement in interactive mode, after control-C during a script invocation with python -i. that way, say at a raw_input('continue->') prompt in my script, I could break out, inspect/modify things, and go right back to the raw_input prompt (or whatever开发者_如何学Go code caused an exception) with a continue command. the break command outside of a loop could also be repurposed for symmetry, but I'd have less use for that. before submitting a PEP for this, I'd like some feedback from the Python community.

it might be possible to do something similar just using a PYTHONSTARTUP script and the inspect module, but if so I haven't figured it out yet.


ctrl-C raised a KeyboardInterrupt exception in your script. Since you didn't catch that exception, the program terminated. Only then the interactive prompt appears.

You can't continue because your program is already over. The fact that you pressed Ctrl-C just raised an exception, the program didn't pause at that exact place. It continued execution, up to the last line, and finished.

There's no way to know where you want to continue to. For that you need a real debugger.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号