[Python-Dev] readonly doc (original) (raw)
Guido van Rossum guido at python.org
Thu Oct 22 19:58:08 CEST 2009
- Previous message: [Python-Dev] readonly __doc__
- Next message: [Python-Dev] readonly __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Well doc isn't a normal attribute -- it doesn't follow inheritance rules.
On Thu, Oct 22, 2009 at 10:25 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
Guido van Rossum <guido python.org> writes:
On Thu, Oct 22, 2009 at 9:45 AM, Antoine Pitrou <solipsis pitrou.net> wrote: > > Speaking of the doc property, I just noticed the following thing on py3k: > >>>> class C: pass > ... >>>> C.doc = "hop" > Traceback (most recent call last): > File "", line 1, in > AttributeError: attribute 'doc' of 'type' objects is not writable > > Is this deliberate? Yes. I might add why I was asking this question. I was trying to demonstrate the use of class decorators and the simplest example I found was to add a docstring to the class. And I was surprised when I saw the following fail with the aforementioned exception: def classdeco(cls): cls.doc = "decorated!" return cls @classdeco class C: pass Regards Antoine.
Python-Dev mailing list Python-Dev at python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] readonly __doc__
- Next message: [Python-Dev] readonly __doc__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]