Documentation string
Skip Montanaro
skip at mojam.com
Thu Aug 26 11:59:18 EDT 1999
sp00fD> Can someone tell me why the
sp00fD> def foo(self):
sp00fD> """A method"""
sp00fD> won't work?
You need to indent it. The def statement opens a new block, which is
required to be indented further than the def's indentation:
def foo(self):
"""a method"""
if (self.spam):
return self.eggs
return self.spamspameggsandspam
You may be confusing the doc string with a comment. The following is valid:
def foo(self):
# a method
if (self.spam):
return self.eggs
return self.spamspameggsandspam
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098 | Python: Programming the way Guido indented...
More information about the Python-list
mailing list