Guido van Rossum <guido <at> python.org> writes: > > On Thu, Oct 22, 2009 at 9:45 AM, Antoine Pitrou <solipsis <at> 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 "<stdin>", line 1, in <module> > > 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.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4