On Thu, Aug 29, 2019 at 10:03 PM Philippe Prados <[email protected]>
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 <[email protected]>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/HCNUWKUZUFYOBJ5YXCSFIFXQRAHTJQYB/
Code of Conduct: http://python.org/psf/codeofconduct/