Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Doc/tutorial/errors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ Syntax Errors
Syntax errors, also known as parsing errors, are perhaps the most common kind of
complaint you get while you are still learning Python::

>>> while True print('Hello world')
>>> a[1]] = 0
File "<stdin>", line 1
while True print('Hello world')
^^^^^
SyntaxError: invalid syntax

The parser repeats the offending line and displays little arrows pointing
at the place where the error was detected. Note that this is not always the
place that needs to be fixed. In the example, the error is detected at the
function :func:`print`, since a colon (``':'``) is missing just before it.
a[1]] = 0
^
SyntaxError: unmatched ']'

The parser repeats the offending line and displays a little arrow pointing
at the earliest point in the line where the error was detected.
Note that this is not always the place that needs to be fixed.
In the example, the arrow points to the extra ``]`` bracket, which is where the
error is detected.

The file name (``<stdin>`` in our example) and line number are printed so you
know where to look in case the input came from a file.
Expand Down
Loading