A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2012-January/115650.html below:

[Python-Dev] Writable __doc__

[Python-Dev] Writable __doc__ [Python-Dev] Writable __doc__Ethan Furman ethan at stoneleaf.us
Thu Jan 19 01:01:23 CET 2012
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?

~Ethan~
More information about the Python-Dev mailing list

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