Oops, you're right.
What I should have said is to use a blank docstring as
follows:
Function docstring.
def foo:
...
or:
Module docstring.
def foo:
...
--- Anthony Baxter [EMAIL PROTECTED] wrote:
On Monday 21 March 2005 20:08, Nicholas Jacobson
wrote:
How do you distinguish
On Tuesday 22 March 2005 05:58, Nicholas Jacobson wrote:
Oops, you're right.
What I should have said is to use a blank docstring as
follows:
It's still unclear to me what a file containing a single docstring
followed by a def() line means. And this ambiguity doesn't seem
to be solvable, so
Rule #1: If the docstring is the first line of a
module, it's the module's docstring.
Rule #2: If the docstring comes right before a
class/function, it's that class/function's docstring.
How do you distinguish between a docstring at the
top of a module
that's immediately followed by a
On Monday 21 March 2005 20:08, Nicholas Jacobson wrote:
How do you distinguish between a docstring at the
top of a module
that's immediately followed by a function? Is it
the module docstring
or the function docstring?
It's both. The docstring would be assigned to both
the module
Nicholas Jacobson wrote:
IIRC, Guido once mentioned that he regretted not
setting function docstrings to come before the
function declaration line, instead of after.
He did, but I don't know how strong that regret is.
i.e.
This describes class Bar.
class Bar:
...
Or with a decorator:
This
Nicholas Jacobson wrote:
IIRC, Guido once mentioned that he regretted not
setting function docstrings to come before the
function declaration line, instead of after.
[ examples deleted ]
I think that commenting the function before its
declaration, at the same tabbed point, increases the
code's
Nicholas Jacobson wrote:
If a programmer wanted a docstring for the function
but not the module, a blank first line would do the
trick. A docstring for the module but not the
function? Put a blank line between the module's
docstring and the function.
-1 on all this making of blank lines
IIRC, Guido once mentioned that he regretted not
setting function docstrings to come before the
function declaration line, instead of after.
i.e.
This describes class Bar.
class Bar:
...
Or with a decorator:
This describes class Bar.
@classmethod
class Bar:
...
Versus the current method: