LoginSignup
1
1

More than 5 years have passed since last update.

PDBの中で複数行のスクリプトを実行する

Posted at

Pythonのデバッガpdbで複数行のスクリプトを実行しようとすると、そのままだとエラーになる。

(Pdb) if root_task in task_sets['completed']:
*** SyntaxError: unexpected EOF while parsing

こういう時は interact コマンドを使うとpythonのインタプリタシェルが立ち上がる。

(Pdb) interact
*interactive*
>>> if root_task in task_sets['completed']:
...     completed_tasks = task_sets['completed']
...     for key in task_sets.keys()

pdbの状態での変数の名前は値を引き継いでいるので、そのまま通常のPythonスクリプトが書ける。

interact
Start an interactive interpreter (using the code module) whose global namespace contains all the (global and local) names found in the current scope.
New in version 3.2.

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1