Documentation string

f_beutlin at f_beutlin at
Thu Aug 26 08:44:34 EDT 1999

In article <7q3c88$k8m$1 at>,
  sp00fD <sp00fD at> wrote:
> Can someone tell me why the
> def foo(self):
> """A method"""
> won't work?
> $ ./ -p BACKUP ./foo /tmp
>   File "./", line 18
>     """A method"""
>                  ^
> SyntaxError: invalid syntax

The problem is simple and easily fixed: the comment is not indented. Try
indenting it, and it'll work (indentation will make the comment part of
the method or function; starting it at the same indentation level as
"def" will make it a new and incorrect command outside the function).

Python-professionals: please forgive me if I'm wrong; I'm new to Python



Sent via
Share what you know. Learn what you don't.

More information about the Python-list mailing list