By philipnorton42
on 13th April 2012
Python doesn't officially support multi-line comments, but there is a way of implementing the same functionality using an existing language construct. Single line comments in Python are written like this:
# This is a single line comment.
You can create a multi-line comment in Python by using a multi-line string. Unless it is part of a docstring at the start of a class, function or module then it is ignored.
''' This is a multiline comment '''
Multi-line strings are used when you want to create a string that is split across several lines. If you create one and don't assign it to a variable then it is just thrown away. Multi-line strings can be used in the following way.
multilinestring = ''' This is a multiline string ''' print multilinestring
Category
Comments
Anonymous - Fri, 12/30/2016 - 20:52
Add new comment