An alternative method for implementing multi-line annotation in Python

Source: Internet
Author: User
This article mainly introduces an alternative method for implementing multi-line annotation in Python. This article uses the Python multi-line text function to implement multi-line annotation in Python, if you need a friend, you can refer to the comments of the Python program and feel like a group. For those who are used to using/**/multi-line comments, in Python, it is very painful to use # to annotate a single line.

The Code is as follows:


# Here is a single line comment
# A = 50
# B = 10
# C = 10


In fact, we can implement multi-line comments through the format defined by multi-line text:

The Code is as follows:


"""
# Multiline comments
A = 50
B = 10
C = 10
"""


This method is not bad. It is no different from/**/multi-line comments, which is useful when debugging code. You can directly use multi-line text definition symbols to comment out some code. Maybe the multi-line text definition function of Python can also be used as annotation, but the Manual does not explicitly write it for multi-line annotation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.