2012/1/18 Ethan Furman <et...@stoneleaf.us>: > Is there a reason why normal classes can't have their __doc__ strings > rewritten? Creating a do-nothing metaclass seems like overkill for such a > simple operation. > > Python 3.2 ... on win32 > --> class Test(): > ... __doc__ = 'am I permanent?' > ... > --> Test.__doc__ > 'am I permanent?' > --> Test.__doc__ = 'yes' > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > AttributeError: attribute '__doc__' of 'type' objects is not writable > --> type(Test) > <class 'type'> > > --> class Meta(type): > ... "only for exists to allow writable __doc__" > ... > --> class Test(metaclass=Meta): > ... __doc__ = 'am I permanent?' > ... > --> Test.__doc__ > 'am I permanent?' > --> Test.__doc__ = 'No!' > --> Test.__doc__ > 'No!' > --> type(Test) > <class '__main__.Meta'> > > Should I create a bug report?
$ ./python Python 3.3.0a0 (default:095de2293f39, Jan 18 2012, 10:34:18) [GCC 4.5.3] on linux Type "help", "copyright", "credits" or "license" for more information. >>> class Test: ... __doc__ = "time machine" ... >>> Test.__doc__ = "strikes again" >>> Test.__doc__ 'strikes again' -- Regards, Benjamin _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com