Interesting. Some apparent downsides:

- doesn't apply to class attributes
- objects with `__slots__` can't dynamically add attributes 

On Wed, 2021-12-15 at 11:13 +1100, Steven D'Aprano wrote:
> Hmmm, well it seems that we already have support for class attribute 
> docstrings, since Python 3.8.
> 
> It's not documented, but soon will be.
> 
> https://bugs.python.org/issue46076
> 
> 
>    class Card:
>       """A card from a standard French deck"""
>       __slots__ = {
>           'suit': 'Either "Spades", "Hearts", "Clubs" or "Diamonds"',
>           'rank': 'A positive integer in the range 2 <= x <= 14'
>           }
> 
> 
> help() already knows to read the docstrings from the slot dict
> values.
> 
> 

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4XBHQSDGK57UDXOCF67XRXC5Q4DDJZSL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to