[Python-ideas] Attribute Docstrings and Annotations
tony at pagedna.com
Tue Jan 2 17:46:29 CET 2007
On Jan 1, 2007, at 10:21 PM, Josiah Carlson wrote:
> Tony Lownds <tony at PageDNA.com> wrote:
>> I'd like to propose annotations and docstrings on attributes for
>> Python 3000
>> with the following Grammar and properties:
>> expr_stmt: test (':' test ['=' (yield_expr|testlist)] |
>> augassign (yield_expr|testlist) |
>> [',' testlist] ('=' (yield_expr|testlist))*
>>>>> class X:
>> ... "class docstring"
>> ... foo: 1 = 1
>> ... bar: 2
>> ... "attribute docstring"
>> ... attr = None
>> ... "another attribute docstring"
>> ... fields = __slots__ = ['fields', 'attr']
>> ... "docstring ignored"
>> ... x, y = 1, 2
> I have never needed attribute annotations, and I've never heard any
> Python developer talk about it being useful to ahve them. -1 for the
> feature in any form.
> The syntax as described is ugly. -100 for the feature if it has the
> syntax provided.
It's the same syntax as function annotations...
def f(name: annotation = value):
name: annotation = value
The syntax was presented on Guido's blog, too.
More information about the Python-ideas