Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comment conventions in python

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?

like image 316
bgcode Avatar asked Aug 17 '26 00:08

bgcode


1 Answers

These are not comments, they are docstrings. Python allows you to define multi-line strings using triplets of either apostrophes or quotation marks, but PEP 257 recommends using the quotation marks with docstrings for consistency. It has no effect on the contents of the string, however.

like image 115
kindall Avatar answered Aug 18 '26 15:08

kindall



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!