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
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: