Multi-line comments(comments block) are used for description of large text of code or comment out chunks of code at the time of debugging application.
Does Python Support Multi-line Comments(like c/c++…)?
Actually in many online tutorial and webstie you will find that multiline_comments are avilable in python(“”” or ”’). but let’s first look at what python creator, “Guido van Rossum” said about fake block commenting style :
- if writing a text in a single line then use double quotes or single quotes in python.
- if writing a poem or songs or multi-line text then to use triple quotes(“”” or ”’).
both two points do not give any error because text within single quotes or double quotes or tripple quotes can be considered as text-constant
The above technique does not create true comments. It simply inserts Text constant that does not change anything or say that this is a regular single line string somewhere in your code. Always keep in mind to indent the first ( “”” or ”’ ) match correctly, otherwise a SyntaxError is generated.
How we comment out chunks of code easily?
Simply select those lines(it means when to copy the text then first select those lines) and then press (cntrl+#) otherwise consecutive # in every lines is the only way.
- Multiline comments in Python
- How do we create multiline comments in Python?
- Comments in Python
- Interesting facts about strings in Python | Set 1
- 10 Interesting modules in Python to play with
- 10 Interesting Python Cool Tricks
- Interesting Python Implementation for Next Greater Elements
- Interesting facts about strings in Python | Set 2 (Slicing)
- G-Fact 19 (Logical and Bitwise Not Operators on Boolean)
- How to write Comments in Python3?
- Py-Facts - 10 interesting facts about Python
- Reusable piece of python functionality for wrapping arbitrary blocks of code : Python Context Managers
- Python - Read blob object in python using wand library
- Reading Python File-Like Objects from C | Python
- Python | Merge Python key values to list
- Python | Convert list to Python array
- Python | PRAW - Python Reddit API Wrapper
- MySQL-Connector-Python module in Python
- Important differences between Python 2.x and Python 3.x with examples
- twitter-text-python (ttp) module - Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet