In this section, we are going to see the trace module. The trace module helps in tracing the program execution. So, whenever your Python program crashes, we can understand where it crashes. We can use trace module by importing it into your script as well as from the command line.
Now, we will create a script named trace_example.py and write the following content in the script:
class Student:
def __init__(self, std):
self.count = std
def go(self):
for i in range(self.count):
print(i)
return
if __name__ == '__main__':
Student(5).go()
The output will be as follows:
student@ubuntu:~$ python3 -m trace --trace trace_example.py
--- modulename: trace_example, funcname: <module>
trace_example.py(1): class...