On Mon, Feb 28, 2011 at 11:38 AM, Simon King <simon.k...@uni-jena.de> wrote: > Hi Robert, > > On 28 Feb., 19:56, Robert Bradshaw <rober...@math.washington.edu> > wrote: >> If you add a "cdef object __doc__" member to that class, you should be >> able to assign to it. > > I am afraid this is not true. > > One is not able to assign it. __doc__ is read only, even if you define > it cpdef or : > > sage: cython('''cdef class C: > ....: "Documentation of C" > ....: cpdef object __doc__ > ....: ''') > sage: c = C() > sage: c? > ... > File: _mnt_local_king__sage_temp_mpc622_11271_tmp_0_spyx_0.pyx > (starting at line 6) Documentation of C > sage: c.__doc__='other documentation' > Traceback (most recent call last) > ... > AttributeError: '_mnt_local_king__sage_temp_mpc622_11271_tmp_0_spyx' > object attribute '__doc__' is read-only
Sorry, I forgot to mention that it must be declared as "cdef public object __doc__". Otherwise it doesn't create a Python-visible wrapper, so you're still (from Python) accessing the class-level __doc__. sage: cython("""cdef class C: ...: cdef public object __doc__""") sage: c = C() sage: c.__doc__ = "my doc" sage: c.__doc__ 'my doc' - Robert -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org