are docstrings for variables a bad idea?

jelle jelleferinga at gmail.com
Fri Apr 21 08:20:21 EDT 2006


---I don't know for sure what you mean by "pop up as doc-string" - I
guess you
want them magically merged into the functions doc string, at least
inside
your editor? That sure could be done - but I personally don't think
that is
too useful. Because you lose context.---

point taken. perhaps only variables declared in the __init__ should be
made available as a doc string.

---IMHO commenting the parameters and results of a function is what
someone
needs who skims the docs for enlightenment---

these are two completely different things:

f = instanceSomeClass() -> 'pops up the __init__ doc string in your
IDE'

now, when this class is instanced, i think this could be useful:

f.someComplexMethod -> 'pops up the variable docstring'

I'm all for DRY -dont repeat yourself-, but DHORYEBNPTMTRYCEBPTSWTITDS
-don't have others repeat your efforts by not providing the means to
reuse your code efficiently by providing them sparsely with the
information to do so-

could have some place in complex classes that are often subclassed.
having the right information at the right time to do so would be quite
a help.
be fair: do you perfectly well know how to subclass a class without
(extensively) reading it back?

perhaps a variable doc here and there would make this slightly easier.

-jelle




More information about the Python-list mailing list