On Fri, Oct 4, 2019 at 7:13 AM Jelle Zijlstra <jelle.zijlstra@gmail.com> wrote:
El jue., 3 oct. 2019 a las 10:04, Philippe Prados (<philippe.prados@gmail.com>) escribió:
Hello everybody,
After the previous discussions, a new simplified version of PEP-0604 was published.
I propose to add a similar syntax of Scala 3 in Python, to accept an or operator.
# Operator for Union assert( int | str == Union[int,str])
The isinstance() and issubclass() were extended to accept this new syntax:
isinstance(int, int | str) It's not really explored. To accept this evolution, the object Union (and dependencies) now be available as a builtin.
By "available as a builtin", do you mean that it will be in the builtins module, so that the `Union` name will always be accessible anywhere, or simply that the `Union` object will be built into the Python interpreter? Only the latter is actually technically necessary as far as I can see. For example, functions are instances of `types.FunctionType`, which is a "builtin" object, but not actually in the `builtins` module.
There are some changes pending on the PEP text and I believe this will be one of the topics discussed. Philippe, can you assess the PR and the comments, and clarify the parts of the proposal regarding this object and where it'll live? ChrisA