interactive shell debugging with pycharm

前端 未结 9 1291
灰色年华
灰色年华 2020-11-30 18:49

I am new to PyCharm. I have been using IDLE for a long time.

It is very convenient to use Python objects after script execution in IDLE. Is there any way to use scr

9条回答
  •  日久生厌
    2020-11-30 19:01

    I found to previous answers from Piga-fetta, Games Brainiac and kobejohn useful, but not satisfying. So I here provide a third option:

    Loading selected code into the console (my suggestion)

    Use Shift + Alt + E to load the selected code or the line in which the cursor is placed into the console and immediately run it. This also have some disadvantages:

    • You have to select the whole file if you need to run the whole file.
    • The code keeps running even if it encounters an error.

    But in return we get a feature that is better than IDLE (in my opinion): Being able to run your code one selection at a time.

    Read about it here.

    Using breakpoints and Evaluate Expression (Alt-F8) (suggested by Piga-fetta)

    This is very useful in big application where we need to debug at certain locations in the code, but not so useful for interactive coding. So this is not what we want.

    Using Tools --> Run Python Console (suggested by Games Brainiac and kobejohn)

    This is want we want, but is is a bit cumbersome, especially if the the module we want to run is not in the root directory of the project.

提交回复
热议问题