Skip to content
Advertisement

Tag: comments

Proper use of comments

For Python code, PEP 257 provides a convention for using docstrings to document structural entities: packages, modules, functions, classes, and methods. This covers pretty much everything. Stack Overflow questions about how to comment Python code invariably elicit answers saying to use docstrings. Where does this leave comments? Is the Pythonic approach to use docstrings exclusively and never use comments? Or do

How do I create multiline comments in Python?

How do I make multi-line comments? Most languages have block comment symbols like: Answer You can use triple-quoted strings. When they’re not a docstring (the first thing in a class/function/module), they are ignored. (Make sure to indent the leading ”’ appropriately to avoid an IndentationError.) Guido van Rossum (creator of Python) tweeted this as a “pro tip”. However, Python’s style

Advertisement