Python error messages are concrete and easy to understand "ga" (SyntaxError on the closing side of triple "" "comments)

Purpose

(Before that,,, I have received "comments" etc., and this article needs correction, I'm sorry. )

I don't have enough experience to compare it with anything, ** Python error messages are concrete and easy to understand ** I feel that. Therefore, the error can be read not only at a glance but also seriously. I feel that it is a shortcut for error resolution.

However, there are times when I don't understand for a moment, so ** Let's calm down on the assumption that you should understand ** This is an article to show such feelings.

SyntaxError on the closing side of triple "" "comments

On the closing side of the supplementary ** triple "" "comment, the meaning of SyntaxError ** is Even though I just wrote a comment, it causes an error, and it is said to be Syntax It means exactly what it says.

Example error message

The code shown here is for issuing an error message. It's not code that can make exactly the same mistakes. I repeat. This is the code to issue an error message. (However, I've seen the same error in a slightly more confusing code.)

Error 1

This is the case where ** Syntax Error ** appears. The code is below.

comment_err1.py


a = 1
b = 2
try:
    a = 0
"""
Try putting 0 in a.
(The code itself has no meaning.)
"""
    b = b/a
except:
    print("data NG!")

The error display is as follows.

C:\_qiita\python_error>python comment1_err1.py
  File "comment1_err1.py", line 8
    (The code itself has no meaning.)
"""
            ^
SyntaxError: invalid syntax

The above move is ** SyntaxError ** because it doesn't make sense after trying to interpret the comment as something meaningful. The above is fine, including the indentation in the comments.

point

** Comments can't go against indentation either. ** **

Summary

I think it's a natural result in terms of composing the error message, but I felt it was easy to understand. .. ..

Related (person)

Things that are not directly related

Use python without stress! (Become familiar with generator. It seems to be since1975.)

Use python without stress! (In Python, everything is implemented as an object) Use python without stress! (Close to Pylint) Use python without stress! (Expression and Statement) Learn Python carefully using both English and Japanese.

from now on

If you have any comments, please let us know. : candy: Will study,,,,

Recommended Posts

Python error messages are concrete and easy to understand "ga" (SyntaxError on the closing side of triple "" "comments)
Python error messages are concrete and easy to understand "ga" (IndexError: list index out of range with element [0])
Python error messages are specific and easy to understand "ga" (... AAA yyy BBB)
Python error messages are specific and easy to understand "ga" (before that, a colon (:) and a semicolon (;))
[Python] Understand the content of error messages
[Python] I tried to analyze the characteristics of thumbnails that are easy to play on YouTube by deep learning
An easy way to pad the number with zeros depending on the number of digits [Python]
Easy way to check the source of Python modules
14 quizzes to understand the surprisingly confusing scope of Python
Use Python to monitor Windows and Mac and collect information on the apps you are working on
[Super easy! ] How to display the contents of dictionaries and lists including Japanese in Python
Make the display of Python module exceptions easier to understand
I want to know the features of Python and pip
Regular expressions that are easy and solid to learn in Python
[Introduction to Python] I compared the naming conventions of C # and Python.
[Python] How to get the first and last days of the month
The story of running python and displaying the results without closing vim
The road to installing Python and Flask on an offline PC
Convert the result of python optparse to dict and utilize it
Verification of the theory that "Python and Swift are quite similar"
How to update the python version of Cloud Shell on GCP
Try to implement and understand the segment tree step by step (python)
[python] A note that started to understand the behavior of matplotlib.pyplot
Use AWS lambda to scrape the news and notify LINE of updates on a regular basis [python]