On Mon, Dec 13, 2021 at 05:10:52PM -0800, Paul Bryan wrote: > In other words, strings would be reserved to specify documentation.
We can't reserve strings to specify documentation. (1) Strings can be used for forward references. class Node: payload: Any # Arbitrary data. next: Node # Fails, because Node doesn't exist yet! So we use a string for forward references: class Node: payload: Any # Arbitrary data. next: "Node" Technically, we could ask folks to write that as next: ForwardRef["Node"] but I think most people will say "Not a chance". Besides, if PEP 563 becomes standard, then all annotations will be strings. (2) Annotated[...] metadata can be arbitrary objects, so we have to assume that somebody out there is already using strings as metadata. This is why I think that the best we can do is an opt-in system where individual classes can choose to use string annotations as docs, but not a language default. But you never know what the Steering Council will say unless you ask. -- Steve _______________________________________________ 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/FIBS54PQVCTYTCIB2LPDF6U3IXUUZ2IU/ Code of Conduct: http://python.org/psf/codeofconduct/