Default indentation of 4 columns

Mark Hammond mhammond at skippinet.com.au
Mon Oct 25 02:17:22 EDT 1999


> > def complex(real=0.0, imag=0.0):
> >     """real=0., imag=0. -> return a complex number.
> >
> >     Keyword arg "real" (default 0.) gives the real part of
> the result.
> >     Keyword arg "imag" (default 0.) gives the imaginary
> part of the result.
> >     """
>
> IIRC there's a stricture in the Style Guide against repeating
arglists
> in doc strings.  It's certainly ugly, since when one looks at the
code
> the information is now present twice (possibly once right and once
> wrong).  Surely the Right Thing is for calltips (and any other tool
> that displays docstrings) to autogenerate the calling syntax from
the
> func_code?

It does do that.  The heuristic is to build the arglist, then use the
first line of the docstring.  In Tim's example, the args would appear
twice in the calltip window too (once built, once from the docstring)

I guess that Tim was actually talking about docstrings coded in C,
where dynamic information about the args is not available (so Im
guessing he used Python code to make the example clearer, but failed
:-)

However, look at "string.split.__doc__" - this does use a style
similar to what Tim described and it is in .py code - and indeed does
end up showing the arg information twice in the calltip window.

So-basically-I-have-no-idea-what-Tim-meant<wink>-ly,

Mark.





More information about the Python-list mailing list