Enter Interactive Mode In Python

后端 未结 7 811
日久生厌
日久生厌 2021-01-30 06:42

I\'m running my Python program and have a point where it would be useful to jump in and see what\'s going on, and then step out again. Sort of like a temporary console mode.

7条回答
  •  一整个雨季
    2021-01-30 07:16

    python -i myapp.py
    

    This will execute myapp.py and drop you in the interactive shell. From there you can execute functions and check their output, with the whole environment (imports, etc.) of myapp.py loaded.

    For something more sophisticated - it would be better to use a debugger like pdb, setting a breakpoint. Also, most IDEs (PyDev, PyCharm, Komodo...) have graphical debuggers.

提交回复
热议问题