By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,095 Members | 1,658 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,095 IT Pros & Developers. It's quick & easy.

Re: Q re documentation Python style

P: n/a
On Jun 8, 5:17 pm, kj <so...@987jk.com.invalidwrote:
I'm a Perlhead trying to learn the Way of Python.
Welcome to the light, my son.

I guess this is a rambling way to ask: are docstrings *it* as far
Python documentation goes? Or is there a second, more flexible
system?

You can define a decorator to inject the docstring; at least the
docstring will not come between the function line and the body.
Define the decorator like this:
def doc(docstring):
def inject_doc(function):
function.func_doc = docstring
return function
return inject_doc
And then you could do this:

@doc("This is the docstring.")
def some_function():
do_whatever()
I think most tools that use docstrings actually execute the module,
which means by the time the tool sees it the docstring will have been
assigned, though I'm not sure they all do.
Carl Banks
Jun 27 '08 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.