+ 1

What's the difference between comments and docstring in python?

for example while running a code . the problem is I find both similar ..how can I use them in programs?

22nd Jul 2018, 10:21 AM
Deesha Devi Raghu
Deesha Devi Raghu - avatar
3 Answers
+ 1
A docstring is like a multi-line comment. A normal comment is a single line comment.
22nd Jul 2018, 11:26 AM
Paul Grasser
Paul Grasser - avatar
+ 1
Docstring can contain more than one comments but comments is just a single line. e.g Docstring= '''ksjsddkdkkdjd snnsjdjdjd snjkdkdkdhdjdkkddj''' comment= #jkssjbddkdk
22nd Jul 2018, 12:03 PM
Maninder $ingh
Maninder $ingh - avatar
0
There's not much difference when you're normally running the code. But docstrings can be accessed from outside the file using the help() function. Docstrings are normally written at the beginning of each module/class explaining what it does. Read more here: https://en.m.wikipedia.org/wiki/Docstring#JUMP_LINK__&&__Python__&&__JUMP_LINK
22nd Jul 2018, 11:36 AM
Kishalaya Saha
Kishalaya Saha - avatar