[Tutor] Re:Comments in Python

kiran at mhowlinux.org kiran at mhowlinux.org
Thu Feb 26 07:45:39 EST 2004


hi,,

There are two styles of comments in python

# single line comment

" " " this is a multiline comment
  which spawns many lines
" " "



multiline comments are also used to embed what are called doc strings in a function

let me explain

if u have a class say of type school
class school:

   """ this class is useful for defining a type of school 
with its strength,affiliation,address etc
this class has following methods and properties
  affilitaion()
  address()
"""
def affiliation(board):
    ....
    ...
    ...
def address(add):
    ...
    ...
    ...



in above piece of code the triple qouted string not only is  a comment
but when i declare an object say
t=school

and then t . __doc__  returns those comments

also help(school)  returns same comments

gud luck
-kiran
Beware the lollipop of mediocrity: lick it once and you suck forever
www.mhowlinux.org- Helping Linux users in Mhow
hi,,

There are two styles of comments in python

# single line comment

" " " this is a multiline comment
  which spawns many lines
" " "



multiline comments are also used to embed what are called doc strings in a function

let me explain

if u have a class say of type school
class school:

   """ this class is useful for defining a type of school 
with its strength,affiliation,address etc
this class has following methods and properties
  affilitaion()
  address()
"""
def affiliation(board):
    ....
    ...
    ...
def address(add):
    ...
    ...
    ...



in above piece of code the triple qouted string not only is  a comment
but when i declare an object say
t=school

and then t . __doc__  returns those comments

also help(school)  returns same comments

gud luck
-kiran
Beware the lollipop of mediocrity: lick it once and you suck forever
www.mhowlinux.org- Helping Linux users in Mhow
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20040226/aa82bc57/attachment.html


More information about the Tutor mailing list