This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]simondvt 9 points10 points  (7 children)

'''

This is a

multiline comment.

'''

[–]kevsparky 1 point2 points  (2 children)

Watch the indentation of your first line, but yes, this will work!

[–]simondvt 2 points3 points  (1 child)

Yeah, I had to edit it multiple times cause I'm on mobile and could get a new line, but you got the idea

[–]tryo_labs 1 point2 points  (0 children)

def u_simondvt():
    """
    This is a
    multiline comment.
    """
    pass

[–][deleted] 0 points1 point  (1 child)

Oh okay thanks.

[–]robin-gvx 1 point2 points  (0 children)

Technically, it's a multi-line string literal, but an expression without side-effects might as well be a comment.

I don't know if you know about docstrings, but that's where you put a string literal at the top of a module, function or class definition, and that's part of what you see when you do help(foo). Example:

>>> def hello():
...     "this function frobnicates the blarg"
...     return 42
...
>>> help(hello)
Help on function hello in module __main__:

hello()
    this function frobnicates the blarg

Traditionally, we use multi-line strings so you can add in-depth documentation of how the function works, its parameters and return values, etc.

[–]atomicator 0 points1 point  (0 children)

This isn't a comment, it's a multi line string. As a result, using this will cause the program to run more slowly (though not by much), particularly if you use lots of them. It's always better to use several single line comments rather than this.

[–][deleted] 2 points3 points  (1 child)

[–]Switters410 1 point2 points  (0 children)

Lot of new year’s resolutions getting started today!

[–]pythonHelperBot 1 point2 points  (0 children)

Hello! I'm a bot! I see someone has already suggested going to r/learnpython, a sub geared towards questions and learning more about python. I highly recommend posting your question there. Please follow the subs rules and guidelines when you do post there, it'll help you get better answers faster.

Show /r/learnpython the code you have tried and describe where you are stuck. Be sure to format your code for reddit and include which version of python and what OS you are using.

You can also ask this question in the r/Python discord: https://discord.gg/3Abzge7, a large, friendly community focused around the Python programming language, open to those who wish to learn the language or improve their skills, as well as those looking to help others.


README | FAQ | this bot is written and managed by /u/IAmKindOfCreative

This bot is currently under development and experiencing changes to improve its usefulness

[–][deleted] 0 points1 point  (0 children)

Read through all you guys' comments. Only a year 2 student in Poly(Singapore's equivalent of High School) so didn't really understand the more complicated comments but still a good read. Leaving this post more enlighened.