Reputation: 1438
When i try to debug this sample script with ipdb:
n = 1
next = 1
print('end')
I can't execute line 3 because python variables obscure pdb commands:
$ ipdb test.py
> /tmp/test.py(1)<module>()
----> 1 n = 1
2 next = 1
3 print('end')
ipdb> next
> /tmp/test.py(2)<module>()
1 n = 1
----> 2 next = 1
3 print('end')
ipdb> next
> /tmp/test.py(3)<module>()
1 n = 1
2 next = 1
----> 3 print('end')
ipdb> next
1
ipdb> n
1
ipdb> !n
1
ipdb> !next
1
How can i proceed further with my code execution when both commands (n/next) aren't recognized anymore? (Let's assume s/step are also obscured by variables).
!!n
alleviates the problem - it runs ipdb version of next
. If only I could alias n !!n
and then repeatedly use Enter
to execute it, the problem would be solved for me. But Enter
just displays variable n
instead of running alias n
(which should resolve into !!n
)The issue was fixed by by: https://github.com/ipython/ipython/pull/10050
Upvotes: 3
Views: 1424
Reputation: 305
The solution is to use brackets (variable_name)
.
For example, if you have one vairable named q
, you want to check it out, if you directly input q
in the prompt, then the ipdb debugging process will break up.
>>> q
Instead, you should input (q)
to ckeck this vairable:
>>> (q)
Upvotes: 0
Reputation: 91
Update in 12/14/2016:
Finally the iPython team decide to revoke this design.
The solution of your problem is use !!
statement to force standard behavior.
> /home/v-zit/test.py(1)<module>()
----> 1 n = 1
2 next = 11
3 print('end')
ipdb> n
> /home/v-zit/test.py(2)<module>()
1 n = 1
----> 2 next = 11
3 print('end')
ipdb> n
1
ipdb> !!n
> /home/v-zit/test.py(3)<module>()
1 n = 1
2 next = 11
----> 3 print('end')
ipdb> next
11
ipdb> !!next
end
--Return--
None
> /home/v-zit/test.py(3)<module>()
1 n = 1
2 next = 11
----> 3 print('end')
ipdb>
Reference:
https://github.com/ipython/ipython/pull/9449
https://github.com/ipython/ipython/pull/10050
Upvotes: 2