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/2019-March/156768.html below:

[Python-Dev] Best way to specify docstrings for member objects

[Python-Dev] Best way to specify docstrings for member objectsSerhiy Storchaka storchaka at gmail.com
Wed Mar 20 03:41:34 EDT 2019
19.03.19 20:55, Raymond Hettinger пише:
> I'm working on ways to make improve help() by giving docstrings to member objects.
> 
> One way to do it is to wait until after the class definition and then make individual, direct assignments to __doc__ attributes.This way widely the separates docstrings from their initial __slots__ definition.   Working downstream from the class definition feels awkward and doesn't look pretty.
> 
> There's another way I would like to propose¹.  The __slots__ definition already works with any iterable including a dictionary (the dict values are ignored), so we could use the values for the  docstrings.

I think it would be nice to separate docstrings from the bytecode. This 
would be allow to have several translated sets of docstrings and load an 
appropriate set depending on user preferences. This would help in 
teaching Python.

It is possible with docstrings of modules, classes, functions, methods 
and properties (created by using the decorator), because the compiler 
knows what string literal is a docstring. But this is impossible with 
namedtuple fields and any of the above ideas for slots.

It would be nice to allow to specify docstrings for slots as for methods 
and properties. Something like in the following pseudocode:

class NormalDist:
     slot mu:
	'''Arithmetic mean'''
     slot sigma:
         '''Standard deviation'''

It would be also nice to annotate slots and add default values (used 
when the slot value was not set).

class NormalDist:
     mu: float = 0.0
	'''Arithmetic mean'''
     sigma: float = 1.0
         '''Standard deviation'''

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