Help text embedding in C code?

J

James Stroud

Hello All,

I have a python module I wrote in C some time ago and I have since
forgotten how to use my functions and so I wanted to add some
doc-strings such that "help(function_name)" would give some help in the
interactive interpreter. In the cPython source, it seems like python
wrapper functions provide this documentation in doc-strings. Is this the
advisable way? It seems silly to have to write a python wrapper around a
python extension just to have doc-strings available. Is it possible to
embed this information in the C source directly or is that too much
trouble and I should just start typing HTML.reStructuredText for this
sort of thing?

James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
C

Carsten Haese

Hello All,

I have a python module I wrote in C some time ago and I have since
forgotten how to use my functions and so I wanted to add some
doc-strings such that "help(function_name)" would give some help in the
interactive interpreter. [...] Is it possible to
embed this information in the C source directly [...] ?

Yes. A doc-string can be provided in the fourth slot of the PyMethodDef
entry. See e.g. /path/to/python/source/Modules/cPickle.c for a randomly
chosen module that has doc strings embedded in the C source.

HTH,
 
J

James Stroud

Carsten said:
Hello All,

I have a python module I wrote in C some time ago and I have since
forgotten how to use my functions and so I wanted to add some
doc-strings such that "help(function_name)" would give some help in the
interactive interpreter. [...] Is it possible to
embed this information in the C source directly [...] ?


Yes. A doc-string can be provided in the fourth slot of the PyMethodDef
entry. See e.g. /path/to/python/source/Modules/cPickle.c for a randomly
chosen module that has doc strings embedded in the C source.

HTH,

Thanks!

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

extension to list extend 2
dict subclass and pickle bug (?) 4
pdb question - spew out "steps" until crash needed 2
WTF? 4
overloading *something 11
Importing to 0
tkinter text width 8
Cleaning up a string 3

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top