How to input from the Python debugger (pdb)
Question:
The question is best illustrated by the following simple example. I am using pdb to debug the following script (it is Python 3):
astring = input("input here: ")
when stepping in the above line, I get the following prompt and type "abc":
input here: abc
But whatever I input from the keyboard, I get an error, e.g.,
NameError: "name 'abc' is not defined"
> /home/wang/tmp/test.py(4)<module>()
-> astring = input("input here: ")
How can I input when debugging?
Answers:
It seems that the "abc" entered is considered an evaluation. However, your program is input("input here "), but the example you give is "input here:" and the output from pdb says "input a line:".
I don’t know whether they are they same program due to these differences. Try entering n (for next line of code) instead of abc and see what happens.
The question is best illustrated by the following simple example. I am using pdb to debug the following script (it is Python 3):
astring = input("input here: ")
when stepping in the above line, I get the following prompt and type "abc":
input here: abc
But whatever I input from the keyboard, I get an error, e.g.,
NameError: "name 'abc' is not defined"
> /home/wang/tmp/test.py(4)<module>()
-> astring = input("input here: ")
How can I input when debugging?
It seems that the "abc" entered is considered an evaluation. However, your program is input("input here "), but the example you give is "input here:" and the output from pdb says "input a line:".
I don’t know whether they are they same program due to these differences. Try entering n (for next line of code) instead of abc and see what happens.