On Tue, Jul 9, 2019 at 4:15 PM Andrew Barnert via Python-ideas < python-ideas@python.org> wrote:
> On Jul 9, 2019, at 13:09, Shay Cohen <sha...@gmail.com> wrote: > > > > >>> a: 3 > > The reason this isn’t a syntax error is that Python allows any valid > expression as an annotation. And “3” is just as valid an expression as > “int”. > > More generally, annotations don’t actually do anything at runtime, except > get stored in an annotation dictionary. > If you're curious where those annotation "definitions" actually disappear off to: `__annotations__` >>> a: 3 >>> __annotations__ {'a': 3} >>> class X: ... b: 42 ... >>> hasattr(X, 'b') False >>> X.__annotations__ {'b': 42}
_______________________________________________ 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/U7EJB3K5UQSOA6DM3OH6RAGN3LFPCVZR/ Code of Conduct: http://python.org/psf/codeofconduct/