doc string substition and overloading __doc__

Arthur ajsiegel at optonline.net
Fri May 2 18:32:15 EDT 2003


Suspect that this has been discussed before, but can't find a discussion.
The output of this script:


class klass1:
        """klass1"""

class klass2:
          """%s""" %'klass2'

class klass3:
        __doc__ = """%s""" %'klass3'

def def1():
        """def1"""

def def2():
         """%s""" %'def2'

def def3():
         __doc__ = """%s""" %'def3'


print klass1.__doc__
print klass2.__doc__
print klass3.__doc__
print def1.__doc__
print def2.__doc__
print def3.__doc__

Being:

klass1
None
klass3
def1
None
None

Raises a few questions in my mind about the string substition in doc
strings, the difference when overloading __doc__, and the difference in the
case of def.

Art







More information about the Python-list mailing list