Q:- Demonstrate the use of pdb to debug a simple python script.
Code
#!/bin/python import pdb pdb.set_trace() a = [1,2,3,4,5] for i in range(0,5): print a[i]
Output
[student@localhost b]$ python debug.py
> /home/student/2101/b/debug.py(7)<module>()
-> a = [1,2,3,4,5]
(Pdb) n
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
> /home/student/2101/b/debug.py(10)<module>()
-> print a[i]
(Pdb) n
1
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
> /home/student/2101/b/debug.py(10)<module>()
-> print a[i]
(Pdb) n
2
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
> /home/student/2101/b/debug.py(10)<module>()
-> print a[i]
(Pdb) n
3
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
> /home/student/2101/b/debug.py(10)<module>()
-> print a[i]
(Pdb) n
4
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
> /home/student/2101/b/debug.py(10)<module>()
-> print a[i]
(Pdb) n
5
> /home/student/2101/b/debug.py(9)<module>()
-> for i in range(0,5):
(Pdb) n
--Return--
> /home/student/2101/b/debug.py(9)<module>()->None
-> for i in range(0,5):
(Pdb) n
Exception AttributeError: "'NoneType' object has no attribute 'path'" in <function _remove at 0x7fbf8fdc3938> ignored
No comments:
Post a Comment