I\'m debugging my Python scripts using pdb and the manual says I can use p variables command to print the values of the specified variables at a certai
As given in this list for multiple languages:
a = 1
b = 1
n = 'value'
#dir() == ['__builtins__', '__doc__', '__name__', '__package__', 'a', 'b', 'n']
for var in dir()[4:]:
value_of_var = eval(var)
print(value_of_var)
Output:
1
1
'value'
Labelling each one is as simple as printing var + " equals " + eval(var)
.
You state your "ideal output" is exactly the result as typing p a, b, ... , n, ...
:
vars = []
for var in dir()[4:-1]
vars.append(var)
print(tuple(vars))
Output looks like:
(1, 1, 'value')