[Cython] Docstrings for 'cdef public' attributes?

Stefan Behnel stefan_ml at behnel.de
Thu Feb 5 20:59:27 CET 2009


Hi,

Jason Evans wrote:
> Is there any reasonable way to attach docstrings to 'cdef public' 
> attributes?

I'm not aware of any, but I miss that feature, too.


>  The following does not work:
> 
> cdef class Spam:
>      cdef public int spam:
>          """
>              Docstring for spam.
>          """

This is not a suitable syntax, as we might allow default values for
attributes one day, as in

	cdef public int spam = 1

Putting the docstring before the declaration doesn't work with Python's
syntax either.

I'm more in favour of a decorator as a potential future syntax:

	@cython.docstring("The infamous spam number")
	cdef public int spam = 1

Could you file a wishlist bug for this?

Thanks,

Stefan


More information about the Cython-dev mailing list