On Thu, Aug 29, 2019 at 10:03 PM Philippe Prados <philippe.pra...@gmail.com> wrote:
> No, it's not possible, because > > >>> int | str > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > TypeError: unsupported operand type(s) for |: 'type' and 'type' > > Regards > > It is possible because: Python 3.7.4 (default, Jul 9 2019, 18:13:23) [Clang 10.0.1 (clang-1001.0.46.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import annotations >>> def foo() -> int | str: ... pass ... >>> foo.__annotations__ {'return': 'int | str'} Please read PEP 563. Regards, -- Inada Naoki <songofaca...@gmail.com>
_______________________________________________ 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/HCNUWKUZUFYOBJ5YXCSFIFXQRAHTJQYB/ Code of Conduct: http://python.org/psf/codeofconduct/