On Wed, Dec 8, 2021 at 1:20 PM Paul Bryan <pbr...@anode.ca> wrote: > I believe a Annotated[..., str] could become an attribute docstring if by > consensus we deem it to be so. I can't see any disadvantages, perhaps save > for the verbosity of `Annotated`. It certainly seems like an advantage to > use an existing mechanism rather than define a new one that would appear to > require changes to the interpreter. >
I think this would be better than nothing. But it is a little verbose. And it requires you to supply the type hint. I use type hinting, but I don't want to use it every time I provide an Annotation/docstring. Maybe we could do both: establish the 2nd argument of Annotated as the docstring (and adjust the output of help() and other tools accordingly), but also provide a new "shortcut syntax" as Steven proposed: E_s : float : "the elastic modulus of steel" ... is sugar for: E_s : typing.Annotated[float, "the elastic modulus of steel"] ...and: x :: "spam" ...is sugar for: x : typing.Annotated[typing.Any, "spam"] --- Ricky. "I've never met a Kentucky man who wasn't either thinking about going home or actually going home." - Happy Chandler
_______________________________________________ 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/KTJ6BTJJJTGS42JLQWMATDLWXGWPZHZT/ Code of Conduct: http://python.org/psf/codeofconduct/