The correct way to do it is to provide a docstring. That way, help(add) will also spit out your comment.

def add(self):
    """Create a new user.

    Line 2 of comment...
    And so on... 
    """

That's three double quotes to open the comment and another three double quotes to end it. You can also use any valid Python string. It doesn't need to be multiline and double quotes can be replaced by single quotes.

See: PEP 257

Answer from Chinmay Kanchi on Stack Overflow
๐ŸŒ
Python
peps.python.org โ€บ pep-0008
PEP 8 โ€“ Style Guide for Python Code | peps.python.org
Write docstrings for all public modules, functions, classes, and methods. Docstrings are not necessary for non-public methods, but you should have a comment that describes what the method does. This comment should appear after the def line. PEP 257 describes good docstring conventions.
Discussions

Comment Etiquette
Comment for future you. If future you needs to spend time remember how an algorithm works, comment it to explain how the algorithm works. Future you will know that a function called check_win() checks win conditions. Future you == other programmers. They don't want to spend time deconstructing your algorithms, tell them how it works so they know without having to break it apart and rubber duck it. Also, use doc-strings and typing, to help LSPs speed things up, too. def my_function(person: str) -> str: """ This is what my function does! """ return f"Hello, {person}!" More on reddit.com
๐ŸŒ r/learnpython
30
13
November 17, 2023
What is the proper way to comment code in Python? - Stack Overflow
I was reading PEP8 and some questions on Stack Overflow, but I was wondering about spaces between comments: Letโ€™s say I have this code: class MyBrowser(QWebPage): ''' Settings for the browser.'... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Comment conventions in python - Stack Overflow
It seems like you can use both '''comments...''' and """comments...""" for multi-line comments. Is there any substantive difference between the two, or is it just a matter of preference? More on stackoverflow.com
๐ŸŒ stackoverflow.com
"Essential Contextual Code Commenting" guideline for (concisely) commenting code - Ideas - Discussions on Python.org
I am proposing a commenting style guideline. This is not initially meant to be a unique commenting guide. The story behind its creation arises from the usage of Large Language Models (LLMs) for code generation. The generated codes are indeed usually oververbose in commenting lines (excessive ... More on discuss.python.org
๐ŸŒ discuss.python.org
0
January 7, 2025
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_comments.asp
Python Comments
#This is a comment #written in #more than just one line print("Hello, World!") Try it Yourself ยป ยท Or, not quite as intended, you can use a multiline string. Since Python will ignore string literals that are not assigned to a variable, you can add a multiline string (triple quotes) in your code, and place your comment inside it:
๐ŸŒ
Real Python
realpython.com โ€บ python-comments-guide
Writing Comments in Python (Guide) โ€“ Real Python
January 25, 2023 - The PEP 257 guidelines have conventions for multiline docstrings as well. These docstrings appear right at the top of a file and include a high-level overview of the entire script and what itโ€™s supposed to do: Python ยท # -*- coding: utf-8 -*- """A module-level docstring Notice the comment above the docstring specifying the encoding.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ comment etiquette
r/learnpython on Reddit: Comment Etiquette
November 17, 2023 -

So I feel a little stupid. I wouldn't call myself a complete beginner anymore, and I'm somewhat able to work my way around python and its libraries, yet I'm baffled by something simple: How the HECK do I comment stuff correctly. I've been programming for a couple of years now, am not only self-taught, but also went to a school that taught me a lot about C#, Databases - the basics. Yet what I never learned was how to comment correctly, how to correctly abbreviate my comments and how to not include essays of unneeded comments, that turn the whole code into 2x the length it needs to be.

I recently came across some of my first projects, in which we were supposed to create a short Rock-Paper-Scissors game and found this:

while game_is_running:
    # any returns True if any of the conditions in the list are True
    if any([wins, losses, ties]) is False: 
        print('Welcome to this short game.')

And some more examples of code from other projects, this time a Tic-Tac-Toe game:

# print the whole game board
def print_game_board(board):

# checks if one of the win conditions has been fullfilled after every input
win_condition()

There are more examples but these are the ones that stuck out to me as unecessary.

So my question is simple: How much is too much.

I kind of feel dumb for even asking, but heck I'm here to learn as are most people.

๐ŸŒ
Google
google.github.io โ€บ styleguide โ€บ pyguide.html
Google Python Style Guide
No: foo = 1000 # comment long_name = 2 # comment that should not be aligned dictionary = { 'foo' : 1, 'long_name': 2, } Most .py files do not need to start with a #! line. Start the main file of a program with #!/usr/bin/env python3 (to support virtualenvs) or #!/usr/bin/python3 per PEP-394.
๐ŸŒ
Liquid Web
liquidweb.com โ€บ home โ€บ a guide to writing comments in python
A Guide to Writing Comments in Python | Liquid Web
January 15, 2026 - In simple terms, a comment is an entry added to the source code to allow a deeper understanding of the logic behind why the code was written the way it was. In Python, the hash (#), number sign, or pound symbol is required before every inline comment.
Find elsewhere
๐ŸŒ
Cornell Computer Science
cs.cornell.edu โ€บ courses โ€บ cs1110 โ€บ 2022fa โ€บ materials โ€บ style
Python Programming Style
August 24, 2019 - Part of these habits concern simple, syntactical measures like using proper spacing, or using naming conventions. The more important part concerns recording enough information in comments for the reader to understand how a program is designed and why. Unlike Java, Python does not have a ...
๐ŸŒ
Rhino
developer.rhino3d.com โ€บ guides โ€บ rhinopython โ€บ python-code-conventions
Rhino - Python Code Conventions
April 29, 2022 - Indent the highest level statements that follow the overview comments two spaces, with each nested block indented an additional two spaces. The following code adheres to Python coding conventions:
๐ŸŒ
Kinstaยฎ
kinsta.com โ€บ home โ€บ resource center โ€บ blog โ€บ python โ€บ create python comments the right way
Python Comments: 5 Best Practices for Writing Them
October 17, 2023 - In Python, a line is declared as a comment when it begins with # symbol. When the Python interpreter encounters # in your code, it ignores anything after that symbol and does not produce any error.
๐ŸŒ
Python.org
discuss.python.org โ€บ ideas
"Essential Contextual Code Commenting" guideline for (concisely) commenting code - Ideas - Discussions on Python.org
January 7, 2025 - I am proposing a commenting style guideline. This is not initially meant to be a unique commenting guide. The story behind its creation arises from the usage of Large Language Models (LLMs) for code generation. The generated codes are indeed usually oververbose in commenting lines (excessive ...
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ commenting-python-code
Commenting Python Code
August 10, 2023 - Version 2 is simpler than version 1. It's originally intended to be used for creating documentation (see more about this below), but it can also be used for multi-line comments. """ LinuxThingy version 1.6.5 Parameters: -t (--text): show the text interface -h (--help): display this help """ Note that the latter version needs to be enclosed in special quotation marks (""") to work, and not hash characters. It is quite common to start a Python file with a few lines of comments.
๐ŸŒ
Python
peps.python.org โ€บ pep-0350
PEP 350 โ€“ Codetags - Python Enhancement Proposals
Each codetag should be inside a comment, and can be any number of lines. It should not share a line with code. It should match the indentation of surrounding code. The end of the codetag is marked by a pair of angle brackets <> containing optional ...
๐ŸŒ
Simplilearn
simplilearn.com โ€บ home โ€บ resources โ€บ software development โ€บ comments in python: why are they important and how to use them
Python Comments: Advantages and Types
July 31, 2025 - Comments in Python is the inclusion of short descriptions along with the code to increase its readability. A developer uses them to write thought process.
๐ŸŒ
Coursera
coursera.org โ€บ tutorials โ€บ python-comment
How to Use a Python Comment: Block, Inline, and Multiline | Coursera
You should also always use double quote characters for triple-quoted strings to align with the docstring convention in the Style Guide for Python Code. ... Another way to create a multiline comment is to wrap it inside a set of triple quotes, similar to a multiline docstring.
๐ŸŒ
PYnative
pynative.com โ€บ home โ€บ python โ€บ python comments
Python Comments [Guide] โ€“ PYnative
August 22, 2022 - Learn Commenting Python Code. Understand the need for comments. Write single-line and multi-line comments. Understand block, inline, and docstring comments.
๐ŸŒ
Docuwriter
docuwriter.ai โ€บ home โ€บ python code commenting guide | docuwriter.ai
Python code commenting guide
Python uses # for single-line comments and """...""" for multi-line comments. Following Python commenting conventions ensures your code is readable and maintainable.