January 2019
Beginner
318 pages
8h 23m
English
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) returnif __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 Student: --- ...
Read now
Unlock full access