[Cython] cdef class and docstrings
David Cournapeau
cournape at gmail.com
Wed Dec 10 09:57:05 CET 2008
On Wed, Dec 10, 2008 at 5:35 PM, Stefan Behnel <stefan_ml at behnel.de> wrote:
> David Cournapeau wrote:
>> Is it possible to include docstring in a cdef class exactly as it
>> would work for python classes, or do I have to use python wrappers
>> around the cython class ? As an example:
>>
>> cdef Yo:
>> def __init__(selg, arg1='arg1'):
>> "Some doc"
>>
>> The Yo.__init__.__doc__ is not "some doc", and I can't get the
>> signature in ipython. Is this expected, or am I doing something wrong
>> here ?
>
> I find this unexpected, too. However, have you tried putting the docstring
> where it actually belongs? As in
>
> cdef class Yo:
> "Some doc"
Hm, why should the __init__ method belong to the class string ? Those
are different, in my mind: the Yo.__doc__ tells about the Yo class
purpose, and the Yo.__init__.__doc__ should give details about the
construction (arguments, + signature in the case of ipython advanced
help options).
The class docstring does work, though; the __init__ is:
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
And Yo.__class__.__doc__ is:
"type(object) -> the object's type\ntype(name, bases, dict) -> a new type"
David
More information about the Cython-dev
mailing list