Python-Ref > Basic usage > Debugging > Read the error messages
 
 

^^->
Klíčová slova
Moduly
Knihovní funkce

Read the error messages

The most basic and yet most important part of bug hunting is to read the error messages that Python throws at you. And by reading I mean proper reading, not just skimming over the text to see that there is an error of some sorts.
The error messages provide you with valuable information about the place in your code where the error occured, what exactly was the reason for the crash and what was the so called "stack" at that point. There is no point in searching for an error in a print "Hello, world!" statement when the error message says that there is a division by zero error.
Take a look at the following example, you can clearly see in the error message that there was a division by zero at line 4. You are even presented with the text of the line. The message could not be simpler.
Expand/Shrink
Zdroj: (debug1-1.py)
  1   a = 0
  2   b = 1
  3   c = a/b   # this is ok
  4   d = b/c   # this is not
stderr:
Traceback (most recent call last):
  File "debug1-1.py", line 4, in ?
    d = b/c   # this is not
ZeroDivisionError: integer division or modulo by zero
Doba běhu: 21.2 ms