[Python-Dev] Writable doc (original) (raw)

Benjamin Peterson benjamin at python.org
Thu Jan 19 01:54:39 CET 2012


2012/1/18 Ethan Furman <ethan at 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 "", line 1, in 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



More information about the Python-Dev mailing list