[PYTHON] Run a multi-line script in a PDB

When I try to run a multi-line script with the Python debugger pdb, I get an error.

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

In this case, use the ʻinteract` command to launch the python interpreter shell.

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

Since the variable name in the pdb state inherits the value, you can write a normal Python script as it is.

https://docs.python.org/3/library/pdb.html

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.

Recommended Posts

Run a multi-line script in a PDB
Run the Python interpreter in a script
Let's run a Bash script in Java
A memorandum to run a python script in a bat file
Run a simple algorithm in Python
Run a local script on a remote host
Use Python3's Subprocess.run () in a CGI script
How to run a Maya Python script
Run a Python script from a C # GUI application
How to run some script regularly in Django
Call a Python script from Embedded Python in C ++ / C ++
Run a python script from excel (using xlwings)
Create a plugin to run Python Doctest in Vim (2)
I made a script to put a snippet in README.md
Create a plugin to run Python Doctest in Vim (1)
dict in dict Makes a dict a dict
What's in that variable (when running a Python script)
Run a Python file with relative import in PyCharm
How to run a Python program from within a shell script
Let's create a script that registers with Ideone.com in Python.
A note for embedding the scripting language in a bash script
Note 2 for embedding the scripting language in a bash script
Process the files in the folder in order with a shell script
I wrote a script to get a popular site in Japan
A set of script files that do wordcloud in Python3
I wrote a script that splits the image in two
Take a screenshot in Python
Create a function in Python
Create a dictionary in Python
Run automatic jobs in python
Debugging with pdb in Python
Run shell commands in python
Run Python unittests in parallel
Collaborate in a remote environment
Run illustrator script from python
Let's try a shell script
Make a bookmarklet in Python
Run background job in fabric
Draw a heart in Python
Run Amazon Linux 2 in VirtualBox
Process the contents of the file in order with a shell script
How to pass arguments to a Python script in SPSS Modeler Batch
Create a shell script to run the python file multiple times
Save the Pydrive authentication file in a different directory from the script
I wrote a function to load a Git extension script in Python
I wrote a script to extract a web page link in Python
How to determine if a shell script was started in bash